count down

simple count down un lcd display
This commit is contained in:
Sergio Álvarez 2016-02-14 16:00:04 +01:00
parent a28b1ec400
commit fe035a4732
1 changed files with 48 additions and 46 deletions

View File

@ -13,30 +13,23 @@
DHT dht(DHT_APin, DHT_Type); DHT dht(DHT_APin, DHT_Type);
LiquidCrystal lcd(9, 10, 4, 5, 6, 7); // syntax: LiquidCrystal(rs, enable, d4, d5, d6, d7) LiquidCrystal lcd(9, 10, 4, 5, 6, 7); // syntax: LiquidCrystal(rs, enable, d4, d5, d6, d7)
// defs int timer = 0;
int ledPin = 13;
void setup() { // put your setup code here, to run once: void setup() { // put your setup code here, to run once:
Serial.begin(9600); Serial.begin(9600);
dht.begin(); dht.begin();
lcd.begin(16, 2); lcd.begin(16, 2);
pinMode(ledPin, OUTPUT);
lcd.print(" hue hue"); pinMode(13, OUTPUT); // 13 es el pin con el led
lcd.setCursor(0, 2);
lcd.print(" boot"); lcd.print(" hue hue hue");
delay(500);
lcd.print(".");
delay(500);
lcd.print(".");
delay(500);
lcd.print(".");
delay(1000);
} }
void loop() { // put your main code here, to run repeatedly: void loop() { // put your main code here, to run repeatedly:
timer--;
if (timer <= 0) {
// Reading temperature or humidity takes about 250 milliseconds! // Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity(); float h = dht.readHumidity();
@ -68,8 +61,17 @@ void loop() { // put your main code here, to run repeatedly:
lcd.print(hic); lcd.print(hic);
lcd.print("C"); lcd.print("C");
digitalWrite(ledPin, HIGH); digitalWrite(13, HIGH);
delay(100); delay(100);
digitalWrite(ledPin, LOW); digitalWrite(13, LOW);
delay(60000); // 1 minuto //delay(60000); // 1 minuto
timer = 60;
}
lcd.setCursor(14, 2);
if (timer < 10)
lcd.print(0);
lcd.print(timer);
delay(1000);
} }