Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Arduino Quiz #11: Functions

Total questions: 18

Worksheet time: 9mins

Name
Class
Date
1.

What is the main advantage of using functions in an Arduino sketch?

a)

They make the code run faster.

b)

They help organize and modularize the code.

c)

They increase the memory usage.

d)

They make the code harder to read.

2.

Which of the following is a required function in an Arduino sketch?

a)

begin()

b)

initialize()

c)

setup()

d)

main()

3.

What does the 'myMultiplyFunction' do in the example provided?

a)

Adds two numbers

b)

Subtracts two numbers

c)

Multiplies two numbers

d)

Divides two numbers

4.

Where should a custom function be declared in an Arduino sketch?

a)

Inside the setup() function

b)

Inside the main() function

c)

Inside the loop() function

d)

Outside any other function

5.

What is the purpose of the 'ReadSens_and_Condition' function?

a)

To initialize a sensor

b)

To write data to a sensor

c)

To read a sensor, average the readings, scale, and invert the result

d)

To read a sensor and return the raw value

6.

How many times does the 'ReadSens_and_Condition' function read the sensor?

a)

Five times

b)

Four times

c)

Six times

d)

Three times

7.

What is the result of the 'myMultiplyFunction' when called with parameters 2 and 3?

a)

8

b)

5

c)

6

d)

7

8.

What does the 'analogRead(0)' function do in the 'ReadSens_and_Condition' function?

a)

Reads a digital pin

b)

Writes to a digital pin

c)

Writes to an analog pin

d)

Reads an analog pin

9.

What is the purpose of the 'Serial.begin(9600)' line in the setup() function?

a)

To initialize the digital pins

b)

To reset the Arduino

c)

To start the serial communication at 9600 baud rate

d)

To stop the serial communication

10.

What does the 'delay(500)' function do in the loop() function?

a)

Pauses the program for 500 microseconds

b)

Pauses the program for 500 milliseconds

c)

Pauses the program for 500 seconds

d)

Pauses the program indefinitely

11.

What is the role of the 'loop()' function in an Arduino sketch?

a)

To run code once

b)

To stop the program

c)

To run code continuously

d)

To initialize variables

12.

Which function is used to read a digital input in Arduino?

a)

analogWrite()

b)

analogRead()

c)

digitalRead()

d)

digitalWrite()

13.

What is the function of 'pinMode()' in an Arduino sketch?

a)

To write a value to a pin

b)

To read the value of a pin

c)

To delay the program execution

d)

To set a pin as input or output

14.

Which function is used to write a digital output in Arduino?

a)

digitalRead()

b)

analogWrite()

c)

analogRead()

d)

digitalWrite()

15.

What is the purpose of the 'loop()' function in an Arduino sketch?

a)

To initialize variables

b)

To run code continuously

c)

To stop the program

d)

To run code once

16.

What is the purpose of the 'setup()' function in an Arduino sketch?

a)

To initialize variables and settings

b)

To stop the program

c)

To run code continuously

d)

To read sensor data

17.

Which function is used to set the mode of a pin in Arduino?

a)

digitalWrite()

b)

analogRead()

c)

digitalRead()

d)

pinMode()

18.

What does the 'analogWrite()' function do in an Arduino sketch?

a)

Reads a digital pin

b)

Writes a digital value to a pin

c)

Reads an analog pin

d)

Writes an analog value to a pin