Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define Botao 5
- #define Rele 6
- //------------------------------
- void setup()
- {
- pinMode(Botao, INPUT_PULLUP);
- pinMode(Rele, OUTPUT);
- }
- //------------------------------
- void loop()
- {
- while (digitalRead(Botao) == LOW) // Se o botao estiver apertado
- {
- delay(2);
- while (digitalRead(Botao) == LOW) // Se o botao continua apertado
- {
- delay(2);
- if (digitalRead(Botao) == HIGH) // Se o botao foi liberado
- {
- digitalWrite(Rele, LOW); // Liga rele
- delay(1000);
- digitalWrite(Rele, HIGH); // Desliga rele
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement