Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ARDUINO Hello, I have the first part but I need part two and three which can be obtained with a slight modification. I don't have

ARDUINO

Hello, I have the first part but I need part two and three which can be obtained with a slight modification. I don't have programming experience, so even getting the first code was pretty challenging for me. Could you please take a look at my first code and come up with Part 2 and 3? I would really appreciate it. Please make sure the code does what it needs to do and try to use basic coding methods, nothing fancy. The simpler you keep it the easier it will be for me to understand. Thank you soo much in advance.

Part 1

Create a program, starting from the SerialEvent example with the Arduino IDE, which multiplies two numbers input one after another via the serial connection and displays the computed value via the serial monitor.

e.g. user input:

2

3

Program responds with echo of input and then result:

2

3

6

Comment every line of code and paste below using Courier New font.

String inputString = ""; // a string to hold incoming data

String inputString1 = ""; // the first variable that does only needs to be displayed

boolean stringComplete = false; // whether the string is complete

float x = 0; // declaring the variable for first number

float y = 0;

boolean firstInput = true;

void setup() {

// initialize serial:

Serial.begin(9600);

// reserve 200 bytes for the inputString:

inputString.reserve(200);

}

void loop() {

// print the string when a newline arrives:

if (stringComplete) {

Serial.print(inputString);

if (firstInput) {

x = inputString.toFloat();

firstInput = false;

}

else {

y = inputString.toFloat();

firstInput = true;

Serial.println(x * y);

}

// clear the string:

inputString = "";

stringComplete = false;

}

}

void serialEvent() {

while (Serial.available()) {

// get the new byte:

char inChar = (char)Serial.read();

// add it to the inputString:

inputString += inChar;

// if the incoming character is a newline, set a flag

// so the main loop can do something about it:

if (inChar == ' ') {

stringComplete = true;

}

}

}

Above is the code for Part 1. Please use it and modify it order to perform the functions asked in Part 2.

Part 2

Modify the program from part one so that it can do any prescribed number of multiplication operations. The program has the user first indicate how many operations will be done, then it requests each number needed for the operations. When complete, the program should then return done running after displaying the results of the operations.

Now modify this code from Part 2 to get it to perform the functions in Part 3.

Part 3

Modify the program from part two so that the programs response is instead a text phrase depending on the result of the operation(s). Values of 0 return no motion via the serial monitor, values below zero return move back, values from greater than 0 but less than or equal to 6 return move forward some, and values greater than 6 return move far forward.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions