Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set pin 13 as an output.
Arduino
pinMode(13, [1]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using INPUT instead of OUTPUT
Using HIGH or LOW in pinMode
✗ Incorrect
To control an LED or other device, the pin must be set as OUTPUT.
2fill in blank
mediumComplete the code to turn the LED on by setting pin 13 HIGH.
Arduino
digitalWrite(13, [1]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOW to turn LED on
Confusing pinMode with digitalWrite
✗ Incorrect
Setting the pin HIGH sends voltage to turn the LED on.
3fill in blank
hardFix the error in the code to read a button state from pin 7.
Arduino
int buttonState = digitalRead([1]);Attempts:
3 left
💡 Hint
Common Mistakes
Using pin mode constants instead of pin number
Using output pins for input reading
✗ Incorrect
digitalRead needs the pin number, here pin 7, to read the button state.
4fill in blank
hardFill both blanks to create a dictionary of pin states for pins 2 and 3.
Arduino
int states[] = {digitalRead([1]), digitalRead([2])};Attempts:
3 left
💡 Hint
Common Mistakes
Using pins not set as input
Using wrong pin numbers
✗ Incorrect
We read the states of pins 2 and 3 to store in the array.
5fill in blank
hardFill all three blanks to create a map of pin numbers to their digital states.
Arduino
int pinStates[] = {digitalRead([1]), digitalRead([2]), digitalRead([3])};Attempts:
3 left
💡 Hint
Common Mistakes
Using pins not configured as inputs
Mixing pin order
✗ Incorrect
We read pins 9, 7, and 8 to get their states in order.
