Jorge_moises

Troca mesma linha com LCD e modulo I2C

Aug 9th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <LiquidCrystal_I2C.h>
  2. #include <Wire.h>
  3.  
  4. LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
  5. unsigned long Tempo1;
  6. unsigned long Tempo2;
  7. byte Flag1 = 0;
  8. byte Flag2 = 1;
  9. //---------------------
  10. void setup()
  11. {
  12. lcd.begin (16, 2);
  13. // Serial.begin(9600);
  14. }
  15. //---------------------
  16. void loop()
  17. {
  18. if (Flag1 == 0)
  19. {
  20. if ((millis() - Tempo1) > 3000)
  21. {
  22. Flag1 = 1;
  23. Flag2 = 0;
  24. Troca1();
  25. Tempo2 = millis();
  26. }
  27. }
  28. if (Flag2 == 0)
  29. {
  30. if ((millis() - Tempo2) > 3000)
  31. {
  32. Flag1 = 0;
  33. Flag2 = 1;
  34. Troca2();
  35. Tempo1 = millis();
  36. }
  37. }
  38. }
  39. //---------------------
  40. void Troca1()
  41. {
  42. lcd.clear();
  43. lcd.setBacklight (HIGH);
  44. lcd.setCursor (0, 0);
  45. lcd.print ("Relogio");
  46. // delay (3000);
  47. // Serial.println("Troca1");
  48. }
  49. //---------------------
  50. void Troca2()
  51. {
  52. lcd.clear();
  53. lcd.setCursor (0, 1);
  54. lcd.print ("DS18B20");
  55. // delay (3000);
  56. // Serial.println("Troca2");
  57. }
Add Comment
Please, Sign In to add comment