Devices & Components
Arduino Uno Rev3
DHT11 Temperature & Humidity Sensor (3 pins)
Grove - 16 x 2 LCD (Black on Red)
Rotary Potentiometer, 10 kohm
Resistor 221 ohm
Project description
Code
Code
arduino
This is the code i used
1// include the library code: 2#include <LiquidCrystal.h> 3#include "DHT.h" 4 5// set the DHT Pin 6#define DHTPIN 8 7 8// initialize the library with the numbers of the interface pins 9LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 10#define DHTTYPE DHT11 11DHT dht(DHTPIN, DHTTYPE); 12 13void setup() { 14 // set up the LCD's number of columns and rows: 15 lcd.begin(16, 2); 16 dht.begin(); 17 18 // Print a message to the LCD. 19 lcd.print("Temp: Humidity:"); 20} 21 22void loop() { 23 delay(500); 24 // set the cursor to column 0, line 1 25 // (note: line 1 is the second row, since counting begins with 0): 26 lcd.setCursor(0, 1); 27 // read humidity 28 float h = dht.readHumidity(); 29 //read temperature in Fahrenheit 30 float f = dht.readTemperature(true); 31 32 if (isnan(h) || isnan(f)) { 33 lcd.print("ERROR"); 34 return; 35 } 36 37 lcd.print(f); 38 lcd.setCursor(7,1); 39 lcd.print(h); 40} 41
Downloadable files
imagen_para_arduino_yWAYbOWqPU.jpeg
imagen_para_arduino_yWAYbOWqPU.jpeg

imagen_para_arduino_yWAYbOWqPU.jpeg
imagen_para_arduino_yWAYbOWqPU.jpeg

Comments
Only logged in users can leave comments