Advertisement
RuiViana

LCD 4seg e 15 minutos

Dec 28th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. unsigned long previousMillis = 0;
  2. unsigned long currentMillis = 0;
  3. int cont = 1;
  4.  
  5. unsigned int Control = 0;
  6. unsigned int Level = 1;
  7. #include <Wire.h>
  8. #include <LiquidCrystal_I2C.h>
  9. // Inicializa o display no endereco 0x27
  10. LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE);
  11.  
  12. // #include <LiquidCrystal.h>
  13. // LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
  14.  
  15. void setup() {
  16. lcd.begin(16,2);
  17.  
  18. // initialize digital pin 13 as an output.
  19. pinMode(13, OUTPUT);
  20. lcd.clear();
  21. currentMillis = millis();
  22. }
  23.  
  24. void loop()
  25. {
  26. if ((millis()-currentMillis>=4000) && (Level == 1))
  27. {
  28. lcd.clear();
  29. lcd.setCursor(2,0);
  30. lcd.print ("Temp: 26C");
  31. Level = 2;
  32. Control++;
  33. currentMillis = millis();
  34. }
  35. if ((millis()-currentMillis>=4000) && (Level == 2))
  36. {
  37. lcd.setCursor(2,1);
  38. lcd.print ("Umid: 97%");
  39. Level = 3;
  40. Control++;
  41. currentMillis = millis();
  42. }
  43. if ((millis()-currentMillis>=4000) && (Level == 3))
  44. {
  45. lcd.clear();
  46. lcd.setCursor(2,0);
  47. lcd.print ("Hora: 09:34");
  48. Level = 4;
  49. Control++;
  50. currentMillis = millis();
  51. }
  52. if ((millis()-currentMillis>=4000) && (Level == 4))
  53. {
  54. lcd.setCursor(2,1);
  55. lcd.print ("Data: 28/12/2015");
  56. Level = 1;
  57. Control++;
  58. currentMillis = millis();
  59. }
  60. if (Control >=225) // 4.000*225 = 900.000
  61. // if (Control >=10) // 4.000*10 = 40.000 40 segundos
  62. {
  63. lcd.clear();
  64. lcd.setCursor(2,0);
  65. lcd.print ("Grava SD");
  66. Control = 0;
  67. Level = 1;
  68. currentMillis = millis();
  69. }
  70.  
  71. digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
  72. delay(500); // wait for a second
  73. digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
  74. delay(500);
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement