Advertisement
Guest User

Untitled

a guest
May 18th, 2015
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. int button = 2;
  2. int buttonValue = 0;
  3. int redlight = 13;
  4. int yellowlight = 12;
  5. int greenlight = 11;
  6.  
  7. void setup(){
  8. pinMode(redlight,OUTPUT);
  9. pinMode(yellowlight,OUTPUT);
  10. pinMode(greenlight,OUTPUT);
  11. pinMode(button,INPUT);
  12. digitalWrite(greenlight,HIGH);
  13. }
  14.  
  15. void loop(){
  16. buttonValue = digitalRead(button);
  17. if (buttonValue == HIGH){
  18. LightsChange();
  19. delay(15000);
  20. }
  21. }
  22.  
  23. void LightsChange(){
  24. digitalWrite(greenlight,LOW);
  25. digitalWrite(yellowlight,HIGH);
  26. delay(3000);
  27. digitalWrite(yellowlight,LOW);
  28. digitalWrite(redlight,HIGH);
  29. delay(5000);
  30.  
  31. digitalWrite(yellowlight,HIGH);
  32. delay(2000);
  33.  
  34. digitalWrite(yellowlight,LOW);
  35. digitalWrite(redlight,LOW);
  36. digitalWrite(greenlight,HIGH);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement