Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10, How do you read values from the Arduino on the computer screen? (2pts) a. th

ID: 2268296 • Letter: 1

Question

10, How do you read values from the Arduino on the computer screen? (2pts) a. the View' button b. the Serial Monitor buion c. the 'Upload' button d you cannot read values from the Anduino on the screen 11. The code below compares the declared valse of integer "x' against 50 and informs the u whether it is equal or not. Identify the error in the following code and describe the possible (4pts) Int × 25; If (x se) Serial.printin("The value is se) Serial.print1n("The value is not sem) Else 12 write-if' statement to display message only if the value stores m the ? variable is between 10 and 20 (not including the values). 4pts) 13. Completely describe the purpose of the folowing statement (4pts) Int input map(analogRead(Ae), e, 1823, e, 255)

Explanation / Answer

10) The serial monitor helps you in reading values of the program in Arduino. You have to initialize serial monitor with set of commands and declare.

Ans: b

11)

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
Int x=25;
If(x=50)
Serial.println("The value is 50");
Else
Serial.println("The value is not 50");
}

The errors are 'Int', 'If', 'Else'.

Since Arduino is case sensitive, it throws error for these instructions

error: 'Int' was not declared in this scope

error: 'If' was not declared in this scope

error: 'Else' was not declared in this scope

To eliminate these errors write the following code:

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
int x=25;
if(x=50)
Serial.println("The value is 50");
else
Serial.println("The value is not 50");
}

12)

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
int z=Serial.read();
if(z>10 && z<20)
Serial.println("The value is in 10 to 20 range");
}

13)

int input= map(analogRead(A0),0,1023,0,255)

Map function re-maps a number from one range to another. i.e A low value from one range will be mapped to another low range and high value from one range will be mapped to another high range.

syntax:

datatype map(long x, long Low_in, long High_in, long Low_out, long High_out)

analogRead(A0) reads data from Anaolog pin 0 from Arduino board

0 which is Low_in will be mapped to 0 in Low_out

1023 which is High_in will be mapped to 255 in High_out.

So after map function the range changes from 0 to 1023 to 0 t0 255.