Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int button = 2;
- int buttonValue = 0;
- int redlight = 13;
- int yellowlight = 12;
- int greenlight = 11;
- void setup(){
- pinMode(redlight,OUTPUT);
- pinMode(yellowlight,OUTPUT);
- pinMode(greenlight,OUTPUT);
- pinMode(button,INPUT);
- digitalWrite(greenlight,HIGH);
- }
- void loop(){
- buttonValue = digitalRead(button);
- if (buttonValue == HIGH){
- LightsChange();
- delay(15000);
- }
- }
- void LightsChange(){
- digitalWrite(greenlight,LOW);
- digitalWrite(yellowlight,HIGH);
- delay(3000);
- digitalWrite(yellowlight,LOW);
- digitalWrite(redlight,HIGH);
- delay(5000);
- digitalWrite(yellowlight,HIGH);
- delay(2000);
- digitalWrite(yellowlight,LOW);
- digitalWrite(redlight,LOW);
- digitalWrite(greenlight,HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement