Controlling Multiple LEDs with Arduino – Post-Test | Lesson 6
1. What does a for loop help with when using multiple LEDs?
Controlling pins one-by-one manually
Repeating the same action for each pin
Slowing down the loop
2. What does pinMode(j, OUTPUT) do inside setup()?
Turns the pin HIGH
Sets the pin to be used for output
Starts serial communication
3. What happens if you skip declaring pinMode?
The LEDs will still work
The sketch will crash
The pins might not behave as expected
4. How can you reverse the order LEDs turn off?
Use the same loop again
Count backward in the second loop
Change delay values
5. Which variable should you update if you add more LEDs?
basePin
numPins
j
6. What does this code do?
if (j % 2 == 0)
Checks if j is even
Skips all LEDs
Adds a delay
7. What can you use to help debug your sketch?
Use Serial.println() statements
Only change delay times
Restart the Arduino every time
8. What do you need to do in code after physically wiring an extra LED to pin 7?
Change basePin to 7
Increase numPins to 6
Move pinMode() outside of setup()
9. How would you turn LEDs off in reverse order (e.g., pin 6 to pin 2)?
Change loop to count down from high pin to low
Change pinMode to INPUT
Delete the first loop
10. How can you make every second LED turn on while skipping the others?
Use a condition that only runs for even pin numbers
Set the delay to zero
Delete the for loop
11. In your own words, explain how you think a for loop could be used to control multiple LEDs connected to an Arduino. If you’re not sure, just describe what you think might happen when the code runs.
12. "We’d love your feedback on this lesson. What went well, and what could be improved?"
Submit Answers