Components

From My wiki
Jump to: navigation, search

Bluetooth

Bluetooth RS232 HC-05

Displays

16 x 2

Maybe your I2C address isn't 0x27.

Click here to find your address.

Library

  #include <Wire.h>
  #include <LiquidCrystal_I2C.h>

  LiquidCrystal_I2C lcd(0x27, 16,2);
  void setup()   
  {
    Serial.begin(9600);  
    lcd.begin();   
    lcd.backlight(); 
    lcd.setCursor(0,0); 
    lcd.print("Hello, world!");
    delay(1000);
    lcd.setCursor(0,1);
    lcd.print("iaspp.com");
  }
  
  void loop() { }

64 x 48

Display

LEDs

All values are for Vcc = +5V

Calculator

WHITE

Long leg to 270 ohms to source

Short leg to ground

RGB

red, common leg, blue, green

For each leg: 270 ohms

Example

Common Anode

Conect the long leg to +5V

Common Cathode

Connect the long leg to ground

Ultra Violet

  • Max. Forward voltage: 1.5V
  • Max. Forward current: 100mA

Resistors

Potentiometer

Potentiometer.jpg

Sensors

Light

Remember to use a pulldown resistor

 const int photo = A0;
 const int led = 3;
 
 void setup() {
   pinMode(photo, INPUT);
   pinMode(led, OUTPUT);
   Serial.begin(9600);
 }
 
 void loop() {
   int in = analogRead(photo);
   Serial.println(in);
   in = map(in, 0, 1023, 0, 255);
   analogWrite(led, 255-in);
 }

Sound

Temperature

Temperature and Humidity

DHT11

Lib: Grove_Temperature_And_Humidity_Sensor

  • pin 1 = vcc
  • pin 2 = data (use pullup 10k resistor)
  • pin 3 = not used
  • pin 4 = ground
  #include <DHT.h>
  #define DHTTYPE DHT11   // DHT 11
  const int DHTPIN = 26;
  DHT dht(DHTPIN, DHTTYPE);
  byte temperature;
  byte humidity;
  
  void setup() {
    pinMode(DHTPIN, INPUT);
    Serial.begin(9600);
    dht.begin();
  }
  
  void loop() {
    float h = dht.readHumidity();
    float t = dht.readTemperature();
  
    // check if returns are valid, if they are NaN (not a number) then something went wrong!
    if (isnan(t) || isnan(h))
    {
      Serial.println("Failed to read from DHT");
    }
    else
    {
      Serial.print("Humidity: ");
      Serial.print(h);
      Serial.print(" %\t");
      Serial.print("Temperature: ");
      Serial.print(t);
      Serial.println(" *C");
    }
  }