Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set GPIO pin 17 as an output.
Raspberry Pi
GPIO.setup(17, GPIO.[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IN' instead of 'OUT' when setting output mode.
Confusing pin mode with pin state (HIGH/LOW).
✗ Incorrect
To set a pin as output, use GPIO.OUT.
2fill in blank
mediumComplete the code to set GPIO pin 22 as an input.
Raspberry Pi
GPIO.setup(22, GPIO.[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'OUT' instead of 'IN' when setting input mode.
Confusing pin mode with pin state.
✗ Incorrect
To read signals from a pin, set it as input using GPIO.IN.
3fill in blank
hardFix the error in setting pin 5 mode to output.
Raspberry Pi
GPIO.setup(5, GPIO.[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'OUTPUT' instead of 'OUT'.
Using 'INPUT' instead of 'IN'.
✗ Incorrect
The correct constant for output mode is GPIO.OUT, not 'OUTPUT'.
4fill in blank
hardFill both blanks to set pin 13 as input with a pull-up resistor.
Raspberry Pi
GPIO.setup(13, GPIO.[1], pull_up_down=GPIO.[2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using output mode instead of input.
Using pull-down resistor instead of pull-up.
✗ Incorrect
Set pin mode to GPIO.IN and enable pull-up resistor with GPIO.PUD_UP.
5fill in blank
hardFill all three blanks to set pin 18 as output and set it HIGH.
Raspberry Pi
GPIO.setup(18, GPIO.[1]) GPIO.output(18, GPIO.[2]) state = GPIO.input(18) == GPIO.[3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using input mode instead of output.
Setting pin state to LOW instead of HIGH.
Comparing input to LOW instead of HIGH.
✗ Incorrect
Set pin 18 as output with GPIO.OUT, set it HIGH, and check if input reads HIGH.