Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned long previousMillis = 0;
- unsigned long currentMillis = 0;
- int cont = 1;
- unsigned int Control = 0;
- unsigned int Level = 1;
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- // Inicializa o display no endereco 0x27
- LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE);
- // #include <LiquidCrystal.h>
- // LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
- void setup() {
- lcd.begin(16,2);
- // initialize digital pin 13 as an output.
- pinMode(13, OUTPUT);
- lcd.clear();
- currentMillis = millis();
- }
- void loop()
- {
- if ((millis()-currentMillis>=4000) && (Level == 1))
- {
- lcd.clear();
- lcd.setCursor(2,0);
- lcd.print ("Temp: 26C");
- Level = 2;
- Control++;
- currentMillis = millis();
- }
- if ((millis()-currentMillis>=4000) && (Level == 2))
- {
- lcd.setCursor(2,1);
- lcd.print ("Umid: 97%");
- Level = 3;
- Control++;
- currentMillis = millis();
- }
- if ((millis()-currentMillis>=4000) && (Level == 3))
- {
- lcd.clear();
- lcd.setCursor(2,0);
- lcd.print ("Hora: 09:34");
- Level = 4;
- Control++;
- currentMillis = millis();
- }
- if ((millis()-currentMillis>=4000) && (Level == 4))
- {
- lcd.setCursor(2,1);
- lcd.print ("Data: 28/12/2015");
- Level = 1;
- Control++;
- currentMillis = millis();
- }
- if (Control >=225) // 4.000*225 = 900.000
- // if (Control >=10) // 4.000*10 = 40.000 40 segundos
- {
- lcd.clear();
- lcd.setCursor(2,0);
- lcd.print ("Grava SD");
- Control = 0;
- Level = 1;
- currentMillis = millis();
- }
- digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(500); // wait for a second
- digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement