From ff4900d5d54803e7b8cedd9317f20401dda8801f Mon Sep 17 00:00:00 2001 From: mm Date: Sun, 20 Feb 2022 16:23:17 -0500 Subject: [PATCH] adding new projects --- LostGame/lost-game.ino | 30 +++++++++++++++++++ TempLCD/DHT11.ino | 65 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 LostGame/lost-game.ino create mode 100644 TempLCD/DHT11.ino diff --git a/LostGame/lost-game.ino b/LostGame/lost-game.ino new file mode 100644 index 0000000..23b8598 --- /dev/null +++ b/LostGame/lost-game.ino @@ -0,0 +1,30 @@ +//YWROBOT +//Compatible with the Arduino IDE 1.0 +//Library version:1.1 +#include +#include + +LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display + +void msg() +{ + lcd.setCursor(0,0); + lcd.print("you just lost"); + lcd.setCursor(8,1); + lcd.print("the game."); +} + +void setup() +{ + lcd.init(); // initialize the lcd + // Print a message to the LCD. + lcd.backlight(); +} + +void loop() +{ + lcd.clear(); + delay(9000); + msg(); + delay(500); +} diff --git a/TempLCD/DHT11.ino b/TempLCD/DHT11.ino new file mode 100644 index 0000000..eb78f7f --- /dev/null +++ b/TempLCD/DHT11.ino @@ -0,0 +1,65 @@ +/* +DHT11 + +This example reads a DHT11 sensor hooked up on pin D7. Reads both +temperature and humidity and sends it to the Serial port + +created in Feb 2019 by D. Cuartielles +based on work by F. Vanzati (2011) and M. Loglio (2013) + +This example code is in the public domain. +*/ + +// include the EduIntro library +#include +#include +#include +LiquidCrystal_I2C lcd(0x3F, 16, 2); + +DHT11 dht11(D9); // creating the object sensor on pin 'D7' + +int C; // temperature C readings are integers +float F; // temperature F readings are returned in float format +int H; // humidity readings are integers + +void setup() +{ + // initialize serial communications at 9600 bps + Serial.begin(9600); + lcd.init(); + lcd.backlight(); +// lcd.print("you just lost the game"); +} + +void loop() +{ + +// lcd.display(); + lcd.clear(); + lcd.home(); + //lcd.print("you just lost the game"); + dht11.update(); + + C = dht11.readCelsius(); // Reading the temperature in Celsius degrees and store in the C variable + F = dht11.readFahrenheit(); // Reading the temperature in Fahrenheit degrees and store in the F variable + H = dht11.readHumidity(); // Reading the humidity index + + // Print the collected data in a row on the Serial Monitor + Serial.print("H: "); + Serial.print(H); + Serial.print("\tC: "); + Serial.print(C); + Serial.print("\tF: "); + Serial.println(F); + lcd.setCursor(0,0); + lcd.print("H: "); + lcd.print(H); + lcd.print("%"); + lcd.setCursor(0,1); + lcd.print("F: "); + lcd.print(F); + lcd.print(" C: "); + lcd.print(C); + + delay(1000); // Wait one second before get another temperature reading +}