Advertisement
RuiViana

Contador_Travado

Jan 25th, 2017
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1.  
  2. #define Ae 3
  3. #define Be 4
  4. #define Ce 5
  5.  
  6. int leitura3a;
  7. unsigned int contEsq3;
  8. unsigned int auxValorEsq;
  9. byte Flag;
  10. #include <LiquidCrystal.h>
  11. LiquidCrystal lcd3(12, 11, 9, 8, 7, 6);
  12. //---------------------------------
  13. void setup()
  14. {
  15.   Serial.begin(9600);
  16. }
  17. //---------------------------------
  18. void loop()
  19. {
  20.   leitura3a = digitalRead(Ae) & !digitalRead(Be) & !digitalRead(Ce);
  21.   if ((leitura3a == 1) && (Flag == 0))
  22.   {
  23.     Flag = 1;
  24.     // Incrementa o valor do contador
  25.      contEsq3 = contEsq3 + 1;
  26.     // Apaga o valor anterior
  27.     lcd3.setCursor(0, 1);
  28.     lcd3.print(" ");
  29.     // Mostra o valor do contador
  30.     lcd3.setCursor(0, 1);
  31.     lcd3.print(contEsq3);
  32.     auxValorEsq = contEsq3;
  33.   }
  34.   if (leitura3a == 0) Flag = 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement