Font size
WorksheetsArduino Quiz #10: Arrays and Loops
Total questions: 17
Worksheet time: 11mins
What is the main purpose of using an array in the Arduino example?
To reduce the memory usage
To make the code more complex
To increase the speed of the program
To store multiple values in a single variable
In the Arduino example, what does the array 'ledPins' represent?
The pin numbers to which LEDs are attached
The sequence of LED colors
The delay times for each LED
The brightness levels of the LEDs
How many LEDs are used in the Arduino example?
4
5
7
6
What is the function of the 'pinMode' function in the setup?
To set the pin as an input
To set the pin as an output
To read the value from the pin
To write a value to the pin
What is the purpose of the 'delay' function in the loop?
To pause the program for a specified time
To turn off the LEDs
To change the LED color
To reset the Arduino board
What is the value of the 'timer' variable in the code?
200
150
100
50
Which one is the correct way to write an array?
int numbers [] = {12,32,32,55,32};
int numbers() = [0,1,4,5,3,4];
int {} numbers = [ 9, 4, 5, 6, 2];
int [] numbers = (32;24;42;54;);
Which of the following is true about the order of pins in the array?
They must be in ascending order
They must be contiguous
They must be in descending order
They can be in any random order
What is the role of the 'for' loop in the setup function?
To write values to each pin
To initialize each pin as an output
To read values from each pin
To initialize each pin as an input
What does the 'digitalWrite' function do in the loop?
It reads the digital value from a pin
It delays the program execution
It writes a digital value to a pin
It initializes the pin mode
What is the purpose of the second 'for' loop in the loop function?
To increase the brightness of LEDs
To turn on LEDs in a random order
To turn off all LEDs simultaneously
To light up LEDs in reverse order
What is the length of the 'ledPins' array?
6
4
7
5
What is the purpose of using resistors with LEDs in the circuit?
To change the color of LEDs
To connect multiple LEDs in series
To protect the LEDs from high current
To increase the brightness of LEDs
How many entries in the following array?
int numbers [] = {12,32,32,55,32};
6
4
7
5
Which one is the correct format to create an array?
float Names {} = [Kenny, Spenny, Wenny, Fenny];
String Names = {Bendy, Fendy, Kendy, Sendy};
String names {} = ("kRUNDY", "bUNDY", "funNDY","GRunDY");
String NaMeZ [] = {"WaCKy", "TaCKy", "BacKy", "MaCKY"};
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?
byte temp = display_LED[6];
char temp = display_LED[6];
char temp = display_LED[7};
unsigned char temp = display_LED[7];
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};
