14 incomingBytel = Serial.read(); // read the first character in the buffer // assign the first character to variable 15 16 // wait for character to be entered into the buffer numValue1= incomingByte1-48; while (!Serial.available()); incomingByte2 = Serial.read(); // read the second character in the buffer 18 numValue2= incomingByte1-48; // assign the second character to variable 19 product = numValue1 * numValue2; 17 20

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

One picture is a practice exercise from my Introduction to Electrical Engineering course with the instructions after the /*.

The other picture is what I did, and it didn't work. It just uses the first number entered as both factors. What should I do instead? Thank you.

sketch_apr7a | Arduino IDE 2.0.4
File Edit Sketch Tools Help
lik
sketch_apr7a.ino
Arduino Uno
1 unsigned char incomingByte
2
unsigned char numValue;
3
4
5
}
void loop() {
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial.print("Start
\n");
=
}
0; // for incoming serial data
7
8
9 incomingByte
10
numValue = incomingByte-48;
11 Serial.print("The number is: ");
12
13
14
15
16
17
18
19
while(!Serial.available()); //wait for character to entered into the buffer
Serial.read(); //read the character in the buffer
=
Serial.print(numValue); //print the input character
Serial.print("\n");
/* In the above code, Arduino will read a numerical character and converted it to its decimal
value. Add code to read a second number. Add code that multiplies those two numbers and prints
the result. Include a copy of your code and a screenshot of the result in your report. */
Transcribed Image Text:sketch_apr7a | Arduino IDE 2.0.4 File Edit Sketch Tools Help lik sketch_apr7a.ino Arduino Uno 1 unsigned char incomingByte 2 unsigned char numValue; 3 4 5 } void loop() { void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps Serial.print("Start \n"); = } 0; // for incoming serial data 7 8 9 incomingByte 10 numValue = incomingByte-48; 11 Serial.print("The number is: "); 12 13 14 15 16 17 18 19 while(!Serial.available()); //wait for character to entered into the buffer Serial.read(); //read the character in the buffer = Serial.print(numValue); //print the input character Serial.print("\n"); /* In the above code, Arduino will read a numerical character and converted it to its decimal value. Add code to read a second number. Add code that multiplies those two numbers and prints the result. Include a copy of your code and a screenshot of the result in your report. */
Activity5b | Arduino IDE 2.0.4
File Edit Sketch Tools Help
Activity5b.ino
U
Arduino Uno
7
8
9
10
lik 11
12
void loop() {
13
15
while (!Serial.available()); // wait for character to be entered into the buffer
14 incomingByte1 = Serial.read(); // read the first character in the buffer
numValue1 = incomingByte1-48; // assign the first character to variable
while (!Serial.available()); // wait for character to be entered into the buffer
incomingByte2 = Serial.read(); // read the second character in the buffer
incomingByte1-48; // assign the second character to variable
16
17
18
numValue2 =
19
*
product = numValue1 numValue2;
20
Serial.print("Single-Digit Multiplication: "); // print restricted operation
21 Serial.print(numValue1); // print the first factor
Serial.print(" X "); // print operator
Serial.print(numValue2); // print the second factor
Serial.print(" = "); // print equal sign
Serial.print (product); // print the product of two single-digit factors
Serial.print("\n");
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial.print("Start \n");
Start
}
22
23
24
25
26
27
}
Output Serial Monitor X
Message (Enter to send message to 'Arduino Uno' on 'COM6')
Single-Digit Multiplication: 7 X 7
Single-Digit Multiplication: 7 X 7
Single-Digit Multiplication: 8 X 8
=
=
=
49
49
64
Transcribed Image Text:Activity5b | Arduino IDE 2.0.4 File Edit Sketch Tools Help Activity5b.ino U Arduino Uno 7 8 9 10 lik 11 12 void loop() { 13 15 while (!Serial.available()); // wait for character to be entered into the buffer 14 incomingByte1 = Serial.read(); // read the first character in the buffer numValue1 = incomingByte1-48; // assign the first character to variable while (!Serial.available()); // wait for character to be entered into the buffer incomingByte2 = Serial.read(); // read the second character in the buffer incomingByte1-48; // assign the second character to variable 16 17 18 numValue2 = 19 * product = numValue1 numValue2; 20 Serial.print("Single-Digit Multiplication: "); // print restricted operation 21 Serial.print(numValue1); // print the first factor Serial.print(" X "); // print operator Serial.print(numValue2); // print the second factor Serial.print(" = "); // print equal sign Serial.print (product); // print the product of two single-digit factors Serial.print("\n"); void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps Serial.print("Start \n"); Start } 22 23 24 25 26 27 } Output Serial Monitor X Message (Enter to send message to 'Arduino Uno' on 'COM6') Single-Digit Multiplication: 7 X 7 Single-Digit Multiplication: 7 X 7 Single-Digit Multiplication: 8 X 8 = = = 49 49 64
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Processes of 3D Graphics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education