Question: Arduino Serial Input and Output Modify the code provided in class to achieve the following: Code Provided: int redLEDPin=9; //Declare redLEDPin an int, and set

Arduino Serial Input and Output

Modify the code provided in class to achieve the following:

Arduino Serial Input and Output Modify the code provided in class to

Code Provided:

int redLEDPin=9; //Declare redLEDPin an int, and set to pin 9 int yellowLEDPin=10; //Declare yellowLEDPin an int, and set to pin 10 int redOnTime=250; //Declare redOnTime an int, and set to 250 mseconds int redOffTime=250; //Declare redOffTime an int, and set to 250 int yellowOnTime=250; //Declare yellowOnTime an int, and set to 250 int yellowOffTime=250; //Declare yellowOffTime an int, and set to 250 int numRedBlinks; int numYellowBlinks=5;

void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(redLEDPin, OUTPUT); // Tell Arduino that redLEDPin is an output pin pinMode(yellowLEDPin, OUTPUT); //Tell Arduino that yellowLEDPin is an output pin }

void loop() { // put your main code here, to run repeatedly: Serial.println("How Many Times Do You Want the Red LED to blink?"); //Prompt User for Input while(Serial.available()==0) { // Wait for User to Input Data } numRedBlinks=Serial.parseInt(); //Read the data the user has input Serial.println("The Red LED is Blinking"); for (int j=1; j In the Serial Monitor, the user should see the question. What is the first digit of your age? Then the Serial Monitor waits the user to enter one number. Let's use m to refer to this number. After that, the user should see the question. What is the second digit of your age? Then the Serial Monitor waits the user to enter one number. Let's use n to refer to this number. After the numbers are entered. The red LED should blink m times and the yellow LED should blink n times. The serial monitor should produce something like the following. COM8 (Arduino/Genuino Uno) What is the first digit of your age? What is the second digit of your age? The Red LED is Blinking 1 2 3 The Yellow LED is Blinking 1 2 What is the first digit of your age

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!