mm
3 years ago
2 changed files with 95 additions and 0 deletions
@ -0,0 +1,30 @@ |
|||||
|
//YWROBOT
|
||||
|
//Compatible with the Arduino IDE 1.0
|
||||
|
//Library version:1.1
|
||||
|
#include <Wire.h> |
||||
|
#include <LiquidCrystal_I2C.h> |
||||
|
|
||||
|
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); |
||||
|
} |
@ -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 <EduIntro.h> |
||||
|
#include <Wire.h> |
||||
|
#include <LiquidCrystal_I2C.h> |
||||
|
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
|
||||
|
} |
Loading…
Reference in new issue