Advertisement
Guest User

Contador de Pulsos

a guest
Aug 22nd, 2020
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. /*
  2. Desenvolvido por Duds Tecnologia
  3. */
  4.  
  5. int contador = 0;
  6. bool inativo = false;
  7.  
  8. void setup() {
  9.   Serial.begin(9600);
  10. }
  11.  
  12. void loop() {
  13.   int leitura = digitalRead(2);
  14.  
  15.   if (!leitura && inativo) {
  16.     contador++;
  17.     inativo = false;
  18.   }
  19.  
  20.   if (!inativo && leitura) {
  21.     inativo = true;
  22.   }
  23.  
  24.   Serial.print("Contador: ");
  25.   Serial.println(contador);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement