You are on page 1of 3

const int green_pin=8;

const int yellow_pin=9;

const int red_pin=10;

const int green_delay=12000;

const int yellow_delay=3000;

const int red_delay=12000;

int button = 11;

void green()

digitalWrite(green_pin, HIGH);

digitalWrite(yellow_pin, LOW);

digitalWrite(red_pin, LOW);

void yellow()

for(int time2=3;time2>0;time2--)

digitalWrite(green_pin, LOW);

digitalWrite(yellow_pin, HIGH);

digitalWrite(red_pin, LOW);

Serial.println(time2);

delay(1000);

}
void red()

for(int time3=12;time3>0;time3--)

digitalWrite(green_pin, LOW);

digitalWrite(yellow_pin, LOW);

digitalWrite(red_pin, HIGH);

Serial.println(time3);

delay(1000);

void setup()

Serial.begin(9600);

pinMode(green_pin, OUTPUT);

pinMode(yellow_pin, OUTPUT);

pinMode(red_pin, OUTPUT);

}
void loop()

green();

if (digitalRead(button) == HIGH)

delay(15); // software debounce

if (digitalRead(button) == HIGH)

yellow();

red();

You might also like