wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Arduino Quiz #10: Arrays and Loops

Total questions: 17

Worksheet time: 11mins

Name
Class
Date
1.

What is the main purpose of using an array in the Arduino example?

a)

To reduce the memory usage

b)

To make the code more complex

c)

To increase the speed of the program

d)

To store multiple values in a single variable

2.

In the Arduino example, what does the array 'ledPins' represent?

a)

The pin numbers to which LEDs are attached

b)

The sequence of LED colors

c)

The delay times for each LED

d)

The brightness levels of the LEDs

3.

How many LEDs are used in the Arduino example?

a)

4

b)

5

c)

7

d)

6

4.

What is the function of the 'pinMode' function in the setup?

a)

To set the pin as an input

b)

To set the pin as an output

c)

To read the value from the pin

d)

To write a value to the pin

5.

What is the purpose of the 'delay' function in the loop?

a)

To pause the program for a specified time

b)

To turn off the LEDs

c)

To change the LED color

d)

To reset the Arduino board

6.

What is the value of the 'timer' variable in the code?

a)

200

b)

150

c)

100

d)

50

7.

Which one is the correct way to write an array?

a)

int numbers [] = {12,32,32,55,32};

b)

int numbers() = [0,1,4,5,3,4];

c)

int {} numbers = [ 9, 4, 5, 6, 2];

d)

int [] numbers = (32;24;42;54;);

8.

Which of the following is true about the order of pins in the array?

a)

They must be in ascending order

b)

They must be contiguous

c)

They must be in descending order

d)

They can be in any random order

9.

What is the role of the 'for' loop in the setup function?

a)

To write values to each pin

b)

To initialize each pin as an output

c)

To read values from each pin

d)

To initialize each pin as an input

10.

What does the 'digitalWrite' function do in the loop?

a)

It reads the digital value from a pin

b)

It delays the program execution

c)

It writes a digital value to a pin

d)

It initializes the pin mode

11.

What is the purpose of the second 'for' loop in the loop function?

a)

To increase the brightness of LEDs

b)

To turn on LEDs in a random order

c)

To turn off all LEDs simultaneously

d)

To light up LEDs in reverse order

12.

What is the length of the 'ledPins' array?

a)

6

b)

4

c)

7

d)

5

13.

What is the purpose of using resistors with LEDs in the circuit?

a)

To change the color of LEDs

b)

To connect multiple LEDs in series

c)

To protect the LEDs from high current

d)

To increase the brightness of LEDs

14.

How many entries in the following array?

int numbers [] = {12,32,32,55,32};

a)

6

b)

4

c)

7

d)

5

15.

Which one is the correct format to create an array?

a)

float Names {} = [Kenny, Spenny, Wenny, Fenny];

b)

String Names = {Bendy, Fendy, Kendy, Sendy};

c)

String names {} = ("kRUNDY", "bUNDY", "funNDY","GRunDY");

d)

String NaMeZ [] = {"WaCKy", "TaCKy", "BacKy", "MaCKY"};

16.

unsigned char display_LED [] = {1,0,0,1,0,0,0,1,0,1,1,0,1,0};

which code will we use to access the 7th entry into our array?

a)

byte temp = display_LED[6];

b)

char temp = display_LED[6];

c)

char temp = display_LED[7};

d)

unsigned char temp = display_LED[7];

17.

Write a function to print all the values of the array: unsigned char display_LED [] = {1,0,0,1,0,0,0,1,0,1,1,0,1,0};

4 lines