Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //**********************************************************//
- //* *//
- //* Lotus board & *//
- //* Grove Sensor Demo *//
- //* *//
- //* by learnelectronics *//
- //* 30 MAR 2020 *//
- //* www.youtube.com/learnelectronics *//
- //* email: arduino0169@gmail.com *//
- //* *//
- //**********************************************************//
- #include <DHT.h> //add DHT sensor library
- #include <rgb_lcd.h> //add LCD library
- #define DHTPIN 2 //set digital pin2 as DHTPIN
- #define DHTTYPE DHT11 //set the sensor type as DHT 11
- DHT dht(DHTPIN, DHTTYPE); //assign dht as the name of DHT sensor, set the sensor pin as DHTPIN(pin2),set the sensor type as DHTTYPE(DHT11)
- rgb_lcd lcd; //assign lcd as the name of rgb_lcd screen
- void setup() {
- dht.begin(); //initialise the dht sensor
- lcd.begin(16, 2); //initialise the lcd screen; set up the lcd's number of columns and rows:
- delay(2000); //wait for 2s
- }
- void loop() {
- int h = dht.readHumidity(); //store the humidity value to h
- int t = dht.readTemperature(); //store the temperature value to t(in Celsius)
- lcd.setCursor(0, 0); //set the LCD cursor to column 0, line 0
- lcd.print("Temperature:"); //Print text temperature: to the LCD
- lcd.setCursor(12, 0); //set the LCD cursor to column 12, line 0
- lcd.print(t); //Print temperature value t to the LCD
- lcd.setCursor(14, 0); //set the LCD cursor to column 14, line 0
- lcd.write(223); //Print temperature º is character 223 on lookup table
- lcd.print("C"); //Print C to the LCD
- lcd.setCursor(0, 1); //set the LCD cursor to column 0, line 1
- lcd.print("Humidity: "); //Print text Humidity: to the LCD
- lcd.setCursor(10, 1); //set the LCD cursor to column 10, line 1
- lcd.print(h); //Print humidity value h to the LCD
- lcd.setCursor(12, 1); //set the LCD cursor to column 12, line 1
- lcd.print("%"); //Print sign % to the LCD
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement