Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the above code to do this problem (below): void setup() { pinMode(13, OUTPUT); Serial.begin(9600); while (!Serial); Serial.println(Input 1 to Turn LED on and 2
Modify the above code to do this problem (below):
void setup() \{ pinMode(13, OUTPUT); Serial.begin(9600); while (!Serial); Serial.println("Input 1 to Turn LED on and 2 to off"); \} void loop ()\{ if (Serial.available()) \{ int state = Serial.parselnt () ; if ( state ==1) \{ digitalWrite(13, HIGH); Serial.println("Command completed LED turned ON"); \} if ( state ==2) \{ digitalWrite(13, LOW); Serial.println("Command completed LED turned OFF"); \} When you press 1 , the green LED should be turned on When you press 2 , the green LED should be turned off When you press 3 , the yellow LED should be turned on When you press 4 , the yellow LED should be turned off When you press 5 , the red LED should be turned on When you press 6 , the red LED should be turned offStep 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