Skip to content
Snippets Groups Projects

I added two arduino files

Closed Hamood Al-Wahaibi requested to merge arduino into main
2 files
+ 96
0
Compare changes
  • Side-by-side
  • Inline
Files
2
temp_humi.ino 0 → 100644
+ 43
0
#include <Wire.h>
#include <rgb_lcd.h>
#include <DHT.h>
#define DHTTYPE DHT20 // DHT 20
/*Notice: The DHT10 and DHT20 is different from other DHT* sensor ,it uses i2c interface rather than one wire*/
/*So it doesn't require a pin.*/
DHT dht(DHTTYPE); // DHT10 DHT20 don't need to define Pin
unsigned long previousMillis = 0; // last time data was sent
const long interval = 10000; // interval at which to send data (milliseconds)
rgb_lcd lcd;
void setup() {
lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
lcd.setRGB(255, 255, 255); // Set the backlight color (in this case, white)
dht.begin();
}
void loop() {
// send data every 10 seconds
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.write(0xDF); // degree symbol
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");
}
}
Loading