0
0
Raspberry Piprogramming~10 mins

First GPIO program (LED blink) 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 GPIO library.

Raspberry Pi
import [1] as GPIO
Drag options to blanks, or click blank then click option'
Aos
Btime
CRPi.GPIO
Dsys
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'time' instead of 'RPi.GPIO'.
Using 'os' or 'sys' which are unrelated to GPIO.
2fill in blank
medium

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

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 GPIO.BOARD instead of GPIO.BCM.
Confusing GPIO.OUT or GPIO.IN as mode settings.
3fill in blank
hard

Fix the error in setting up pin 18 as an output.

Raspberry Pi
GPIO.setup(18, [1])
Drag options to blanks, or click blank then click option'
AGPIO.OUT
BGPIO.PWM
CGPIO.INPUT
DGPIO.IN
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.IN or GPIO.INPUT instead of GPIO.OUT.
Using GPIO.PWM which is for pulse-width modulation, not basic output.
4fill in blank
hard

Fill both blanks to turn the LED on and then off.

Raspberry Pi
GPIO.output(18, [1])
time.sleep(1)
GPIO.output(18, [2])
Drag options to blanks, or click blank then click option'
AGPIO.HIGH
BGPIO.LOW
CGPIO.OUT
DGPIO.IN
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO.OUT or GPIO.IN as output values.
Reversing HIGH and LOW.
5fill in blank
hard

Fill the blanks to clean up GPIO after blinking.

Raspberry Pi
try:
    GPIO.output(18, [1])
finally:
    GPIO.[2]()
Drag options to blanks, or click blank then click option'
AGPIO.HIGH
Bcleanup
Csetmode
DGPIO.LOW
Attempts:
3 left
💡 Hint
Common Mistakes
Not calling GPIO.cleanup() after use.
Using GPIO.HIGH instead of GPIO.LOW to turn off LED.