Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set GPIO pin 18 as output.
Raspberry Pi
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(18, [1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.IN instead of GPIO.OUT
Confusing pin modes with communication protocols
✗ Incorrect
GPIO.OUT sets the pin as an output pin so you can send signals.
2fill in blank
mediumComplete the code to turn GPIO pin 18 ON (set it HIGH).
Raspberry Pi
GPIO.output(18, [1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.LOW to turn the pin ON
Using non-existent constants like GPIO.ON
✗ Incorrect
GPIO.HIGH sets the pin voltage to high, turning it ON.
3fill in blank
hardFix the error in the code to turn GPIO pin 23 OFF (set it LOW).
Raspberry Pi
GPIO.output(23, [1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.HIGH to turn the pin OFF
Using invalid constants like GPIO.ON
✗ Incorrect
GPIO.LOW sets the pin voltage to low, turning it OFF.
4fill in blank
hardFill both blanks to create a dictionary of pin states for pins 17 and 27, setting 17 HIGH and 27 LOW.
Raspberry Pi
pin_states = {17: [1], 27: [2] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.OUT or GPIO.IN as pin states
Mixing up HIGH and LOW values
✗ Incorrect
Pin 17 is set HIGH to turn ON, pin 27 is set LOW to turn OFF.
5fill in blank
hardFill all three blanks to set up pin 22 as output, turn it ON, and then clean up GPIO.
Raspberry Pi
GPIO.setup(22, [1]) GPIO.output(22, [2]) GPIO.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.IN instead of GPIO.OUT for setup
Forgetting to call cleanup()
Using wrong constants for output
✗ Incorrect
First, set pin 22 as output with GPIO.OUT, then turn it ON with GPIO.HIGH, and finally clean up with GPIO.cleanup().