Question
Using an Arduino. Modify our original traffic light to have 2 sides, and let the user enter the time (in seconds for each color [red,
Using an Arduino. Modify our original traffic light to have 2 sides, and let the user enter the time (in seconds for each color [red, yellow, green]
We want the user delay to override the delay I have given as default value permanently.
I use a MEGA 2560 Arduino.
This is my origonal code.
int ledDelay = 2000; int redPin = 10; int yellowPin = 9; int greenPin = 8;
void setup() { pinMode(redPin, OUTPUT); pinMode(yellowPin, OUTPUT); pinMode(greenPin, OUTPUT); }
void loop() { // turn red on digitalWrite(redPin, HIGH); delay(ledDelay);
digitalWrite(redPin, LOW); digitalWrite(yellowPin, HIGH); delay(ledDelay);
digitalWrite(greenPin, HIGH); digitalWrite(yellowPin, LOW); delay(ledDelay);
digitalWrite(yellowPin, HIGH); digitalWrite(greenPin, LOW); delay(ledDelay);
digitalWrite(yellowPin, LOW);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started