0
0
Raspberry Piprogramming~10 mins

Why gpiozero simplifies hardware in Raspberry Pi - Test Your Understanding

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

Complete the code to import the gpiozero library.

Raspberry Pi
from gpiozero import [1]
Drag options to blanks, or click blank then click option'
AGPIO
BLED
CPin
DBoard
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'GPIO' which is not a class in gpiozero
Using 'Pin' or 'Board' which are not classes to control LEDs
2fill in blank
medium

Complete the code to create an LED object on GPIO pin 17.

Raspberry Pi
led = LED([1])
Drag options to blanks, or click blank then click option'
A27
B5
C22
D17
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing pin numbers not matching the example
Confusing physical pin numbers with GPIO numbers
3fill in blank
hard

Fix the error in the code to turn the LED on.

Raspberry Pi
led.[1]()
Drag options to blanks, or click blank then click option'
Aoff
Benable
Con
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'off' which turns the LED off
Using 'start' or 'enable' which are not gpiozero methods
4fill in blank
hard

Fill both blanks to create a Button on pin 2 and check if it is pressed.

Raspberry Pi
button = Button([1])
if button.[2]:
    print('Pressed!')
Drag options to blanks, or click blank then click option'
A2
B3
Cis_pressed
Dpressed
Attempts:
3 left
💡 Hint
Common Mistakes
Using pin 3 instead of 2
Using 'pressed' which is not a gpiozero property
5fill in blank
hard

Fill all three blanks to create a PWMLED on pin 18, set brightness to 50%, and turn it on.

Raspberry Pi
pwm_led = PWMLED([1])
pwm_led.[2] = [3]
pwm_led.on()
Drag options to blanks, or click blank then click option'
A18
Bbrightness
C0.5
D17
Attempts:
3 left
💡 Hint
Common Mistakes
Using pin 17 instead of 18
Setting brightness to 1 instead of 0.5