// C++ code
//
int a = 0;
void setup()
{
DDRD = 0b11100000;
}
void red()
{
PORTD = 0b10000000;
a=1;
}
void yellow()
{
PORTD = 0b01000000;
a=2;
}
void green()
{
PORTD = 0b00100000;
}
void loop()
{
if (a == 0){
attachInterrupt(digitalPinToInterrupt(2),red,HIGH);
}
delay(200);
if (a == 1){
attachInterrupt(digitalPinToInterrupt(2),yellow,HIGH);
}
delay(200);
if (a == 2){
attachInterrupt(digitalPinToInterrupt(2),green,HIGH);
}
}