top of page
Alexis Smith

[Arduino Quiz1] Stoplight- Alexis Smith

Updated: Mar 2, 2019





(Video to be uploaded)


Code:


int redC = 12;

int yellowC = 11;

int greenC = 10;


int redP = 9;

int greenP = 8;



void setup()

{

pinMode(13,INPUT_PULLUP);

for(int led = 12; led > 7; led--)

{

pinMode(led, OUTPUT);

}

}

void loop() {

int switchVAL = digitalRead(13);

if(switchVAL==HIGH){

digitalWrite(redC,LOW);

digitalWrite(greenC,HIGH);

digitalWrite(redP,HIGH);

digitalWrite(greenP,LOW);

}

else if(switchVAL==LOW){

digitalWrite(greenC,LOW);

digitalWrite(yellowC,HIGH);

delay(500);

digitalWrite(yellowC,LOW);

digitalWrite(redC,HIGH);

digitalWrite(redP,LOW);

digitalWrite(greenP,HIGH);

delay(5000);

for(int signalLED=1; signalLED<6; signalLED++){

digitalWrite(8,LOW);

delay(500);

digitalWrite(8,HIGH);

delay(500);

}

}

}



5 views0 comments

Comments


bottom of page