RuiViana

Tempo_3Seg.ino

May 17th, 2021 (edited)
348
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define btdescargabaixa  6
  2. unsigned long tempo = 0;
  3. //-------------------------------------------
  4. void setup() {
  5.   pinMode(btdescargabaixa, INPUT);
  6.   pinMode(5, OUTPUT);
  7.   tempo = millis();
  8. }
  9. //-------------------------------------------
  10. void loop() {
  11.   while (digitalRead (btdescargabaixa) == HIGH)
  12.   {
  13.     if (millis() - tempo >= 3000)
  14.     {
  15.       digitalWrite (5, LOW);
  16.     }
  17.     else
  18.     {
  19.       digitalWrite (5, HIGH);
  20.     }
  21.   }
  22.   if(digitalRead (btdescargabaixa) == LOW)
  23.   {
  24.     digitalWrite (5, LOW);
  25.     tempo = millis();
  26.   }
  27. }
RAW Paste Data