Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

LCD Wiring Connections

 LCD RS pin to digital pin 12


 LCD Enable pin to digital pin 11
 LCD R/W pin to GND
 LCD D4 pin to digital pin 5
 LCD D5 pin to digital pin 4
 LCD D6 pin to digital pin 3
 LCD D7 pin to digital pin 2

Sample Code

#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
DHT22
 a basic, low-cost digital temperature and humidity sensor
 it uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and
spits out a digital signal on the data pin (no analog input pins needed
 can only get new data from it once every 2 seconds

Sample Code

#include <SimpleDHT.h>
int pinDHT22 = 8;
SimpleDHT22 dht22(pinDHT22);

void setup(void) {
Serial.begin(9600);
}

void loop(void)
{
float temperature = 0;
float humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht22.read2(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
//Serial.print("Read DHT22 failed, err="); Serial.println(err);delay(2000);
return;
}
Serial.print("TEMP:"); Serial.println(temperature);
Serial.print("HUMI:"); Serial.println(humidity);
Serial.println("------");
delay(1000);

You might also like