Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #define LED1 2
  2. #define LED2 3
  3. #define LED3 4
  4. #define PULS 10
  5. int PREMUTO;
  6. long tempo;
  7.  
  8. void setup()
  9. {
  10. pinMode(LED1, OUTPUT);
  11. pinMode(LED2, OUTPUT);
  12. pinMode(LED3, OUTPUT);
  13. pinMode(PULS, INPUT_PULLUP);
  14. }
  15.  
  16. void loop()
  17. {
  18. PREMUTO = digitalRead(PULS);
  19.  
  20. if (PREMUTO==1)
  21. tempo=millis();
  22.  
  23. if (millis()>=tempo+1000)
  24. {digitalWrite(LED1,!digitalRead(LED1));}
  25. tempo=millis();
  26.  
  27. if (digitalRead(LED1)==1)
  28. else if (digitalRead(PULS)==1)
  29. digitalWrite(LED1,1);
  30.  
  31.  
  32. }
  33. /*switch(tempo)
  34. {
  35. case 1: if (PREMUTO==1)
  36. tempo=millis();
  37. break;
  38.  
  39. case 2: if (PREMUTO==0)
  40. tempo=tempo;
  41. break;
  42. }
  43.  
  44. if(tempo>=1000) digitalWrite(LED1,1);
  45. if(tempo>=2000) digitalWrite(LED2,1);
  46. if(tempo>=3000) digitalWrite(LED3,1);
  47. if(tempo>=4000) digitalWrite(LED1,0);
  48. digitalWrite(LED2,0);
  49. digitalWrite(LED3,0);
  50. tempo==0;*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement