wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz | Distance meter code arduino

Total questions: 10

Worksheet time: 7mins

Name
Class
Date
1.

What is the primary purpose of the 'trigPin' in this circuit?

a)

To provide power to the LEDs.

b)

To calculate the distance in centimeters.

c)

To send out an ultrasonic sound pulse.

d)

To listen for the returning echo.

2.

Which constant is used to represent the speed of sound in the distance calculation formula?

a)

2000

b)

10

c)

0.0340

d)

9600

3.

What is the function of the code: 'if(newValue != oldValue)'?

a)

To check if the distance is greater than 15cm.

b)

To blink the LEDs faster.

c)

To reset the sensor if it gets stuck.

d)

To ensure distance is only printed to the Serial Monitor when the value changes.

4.

Why is the calculation divided by 2 in the line: 'distanceCm = duration * 0.0340 / 2;'?

a)

To account for the two LEDs used in the project.

b)

To average two separate readings taken by the sensor.

c)

Because the sound pulse travels to the object and then back to the sensor.

d)

To convert the measurement from millimeters to centimeters.

5.

Which Arduino pin is configured to receive the pulse signal from the ultrasonic sensor?

a)

9

b)

0

c)

10

d)

3

6.

What is the data type of the 'duration' variable, and why is it used?

a)

void, because it represents an empty signal.

b)

long, because the microsecond value can exceed the capacity of a standard 'int'.

c)

int, because distances are usually small numbers.

d)

float, to allow for decimal precision in time.

7.

What line of code establishes the data link between the Arduino and the computer?

a)

void setup() {

b)

digitalWrite(trigPin, LOW);

c)

Serial.begin(9600);

d)

pinMode(trigPin, OUTPUT);

8.

What happens if an object moves while the 'delay(2000)' at the end of the loop is active?

a)

The distance value on the Serial Monitor will update in real-time.

b)

The LEDs will change color instantly.

c)

The Arduino pauses and will not detect any movement until the 2 seconds have passed.

d)

The sensor stores the movement in a buffer for later.

9.

What is the result of the code 'digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);'?

a)

It pauses the script for 10 seconds to wait for an echo.

b)

It resets the Arduino's internal timer to zero.

c)

It creates a 10-microsecond high-voltage pulse to trigger the sensor.

d)

It makes the green LED stay on for 10 microseconds.

10.

Which command is used to measure the time it takes for the echo to return?

a)

delayMicroseconds(duration);

b)

digitalRead(echoPin);

c)

pulseIn(echoPin, HIGH);

d)

Serial.print(duration);