Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define the LED pin number.
Arduino
const int ledPin = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name instead of a pin number.
Using a constant like HIGH or INPUT instead of a pin number.
✗ Incorrect
The LED is connected to pin 13, so we assign 13 to ledPin.
2fill in blank
mediumComplete the code to set the LED pin as an output in the setup function.
Arduino
void setup() {
pinMode([1], OUTPUT);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a constant like INPUT instead of the pin variable.
Using a function name instead of a pin number.
✗ Incorrect
We use ledPin to refer to the pin number and set it as OUTPUT.
3fill in blank
hardFix the error in the code to turn the LED on.
Arduino
void loop() {
digitalWrite([1], HIGH);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using INPUT or pinMode instead of the pin variable.
Using LOW instead of HIGH to turn the LED on.
✗ Incorrect
We must use ledPin to specify which pin to set HIGH.
4fill in blank
hardFill both blanks to create a comment documenting the LED pin number.
Arduino
// [1] is connected to pin [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the LED with the button.
Using the wrong pin number in the comment.
✗ Incorrect
This comment explains that the LED is connected to pin 13.
5fill in blank
hardFill all three blanks to create a dictionary mapping pin names to pin numbers.
Arduino
const int pins[] = { [1], [2], [3] }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of pin numbers.
Repeating the wrong pin numbers.
✗ Incorrect
The array holds pin numbers 13, 7, and 13 for LED and button pins.