Project เซ็นเซอร์วัดอุณหภูมิ
อุปกรณ์
- Arduino Nano ( You can use other boards such as Arduino Uno, Mega ….)
- DHT11 ( Temperature and Humidity Sensor)
- 16×2 LCD
- Resistor 220 Ohms
- Jumper wires
- Bread Board
ตัวอย่างโค้ด
#include <dht.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
dht DHT;
#define DHT11_PIN 7
void setup(){
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print(“www.Electronics”);
delay(1000);
lcd.setCursor(0,1);
lcd.print(“Lovers.com”);
delay(7000);
}
void loop()
{
int chk = DHT.read11(DHT11_PIN);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Temp: “);
lcd.print(DHT.temperature);
lcd.print((char)223);
lcd.print(“C”);
lcd.setCursor(0,1);
lcd.print(“Humidity: “);
lcd.print(DHT.humidity);
lcd.print(“%”);
delay(1000);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น