0
0
Raspberry Piprogramming~10 mins

RPi.GPIO library setup in Raspberry Pi - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the RPi.GPIO library with the common alias.

Raspberry Pi
import [1] as GPIO
Drag options to blanks, or click blank then click option'
ARPi.GPIO
Bgpiozero
CGPIO
Draspberry_gpio
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gpiozero' instead of 'RPi.GPIO' which is a different library.
Trying to import 'GPIO' directly without the full library name.
2fill in blank
medium

Complete the code to set the GPIO numbering mode to BCM.

Raspberry Pi
GPIO.setmode([1])
Drag options to blanks, or click blank then click option'
AGPIO.BCM
BGPIO.BOARD
CGPIO.OUT
DGPIO.IN
Attempts:
3 left
💡 Hint
Common Mistakes
Using BOARD mode when BCM mode is required.
Passing direction constants like OUT or IN instead of mode.
3fill in blank
hard

Fix the error in the code to clean up GPIO settings at the end.

Raspberry Pi
GPIO.[1]()
Drag options to blanks, or click blank then click option'
Aclose
Bclear
Ccleanup
Dreset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'clear' or 'reset' which are not valid methods.
Forgetting to call cleanup causing warnings on next run.
4fill in blank
hard

Fill both blanks to set up a GPIO pin 18 as an output.

Raspberry Pi
GPIO.setup([1], [2])
Drag options to blanks, or click blank then click option'
A18
BGPIO.OUT
CGPIO.IN
D17
Attempts:
3 left
💡 Hint
Common Mistakes
Using pin 17 instead of 18.
Setting pin as input instead of output.
5fill in blank
hard

Fill all three blanks to set pin 23 as input with a pull-up resistor.

Raspberry Pi
GPIO.setup([1], [2], pull_up_down=GPIO.[3])
Drag options to blanks, or click blank then click option'
A23
BGPIO.IN
CPUD_UP
DGPIO.OUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.OUT instead of GPIO.IN for input pin.
Using PUD_DOWN instead of PUD_UP for pull-up resistor.