Question: 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() \{Modify the above code to do this problem (below):

pinMode(13, OUTPUT); Serial.begin(9600); while (!Serial); Serial.println("Input 1 to Turn LED on and

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 off

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!