Advertisement
RuiViana

Aperta_Acende_LED

Dec 7th, 2016
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #define botao1 11                           // Port para o botao
  2. #define LED 10                              // Port para o LED
  3. byte debouc = 2;                            // Valor de delay para debouncing
  4. //---------------------------
  5. void setup()
  6. {
  7.   pinMode(LED, OUTPUT);
  8.   pinMode(botao1, INPUT_PULLUP);
  9. }
  10. //-------------------------
  11. void loop()
  12. {
  13.   while (digitalRead(botao1) == LOW)      // Se o botao estiver apertado
  14.   {
  15.     delay(debouc);
  16.     while (digitalRead(botao1) == LOW)    // Se o botao continua apertado
  17.     {
  18.       delay(debouc);
  19.       if (digitalRead(botao1) == HIGH)    // Se o botïao foi liberado
  20.       {
  21.         digitalWrite(LED, HIGH);          // Acende LED
  22.         delay(600000;
  23.         digitalWrite(LED, LOW);          // Apaga LED
  24.       }
  25.     }
  26.   }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement