Advertisement
RuiViana

Debouncing

Oct 17th, 2016
2,869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define botao1 11                         // Port para o botao
  2. byte debouc = 2;                           // Valor de delay para debouncing
  3. //---------------------------
  4. void setup()
  5. {
  6. ;
  7. }
  8. //-------------------------
  9. void loop()
  10. {
  11.   while (digitalRead(botao1) == LOW)      // Se o botao estiver apertado
  12.   {
  13.     delay(debouc);
  14.     while (digitalRead(botao1) == LOW)    // Se o botao continua apertado
  15.     {
  16.       delay(debouc);
  17.       if (digitalRead(botao1) == HIGH)    // Se o botïao foi liberado
  18.       {
  19.         ;                                 // aqui o code
  20.       }
  21.     }
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement