0
0
Raspberry Piprogramming~5 mins

LED class and methods in Raspberry Pi - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the LED class in Raspberry Pi programming?
The LED class is used to control an LED light connected to the Raspberry Pi's GPIO pins. It allows turning the LED on, off, and blinking it through simple methods.
Click to reveal answer
beginner
Name three common methods of the LED class and their functions.
  • on(): Turns the LED light on.
  • off(): Turns the LED light off.
  • blink(): Makes the LED blink on and off repeatedly.
Click to reveal answer
beginner
How do you create an LED object for GPIO pin 17 in Python on Raspberry Pi?
You import the LED class and create an instance like this:<br><pre>from gpiozero import LED
led = LED(17)</pre>
Click to reveal answer
intermediate
What happens if you call led.blink() without any arguments?
The LED will blink on and off repeatedly with default timing: 1 second on, 1 second off, until stopped.
Click to reveal answer
beginner
How can you stop an LED from blinking once it has started?
You call the led.off() method to turn off the LED and stop blinking.
Click to reveal answer
Which method turns the LED light on?
Aon()
Boff()
Cblink()
Dstart()
What argument do you pass to the LED class when creating an LED object?
ABlink speed
BLED color
CVoltage level
DGPIO pin number
What does the blink() method do by default?
ATurns LED on permanently
BTurns LED off permanently
CMakes LED blink on and off repeatedly
DChanges LED color
How do you stop an LED from blinking?
ACall led.stop()
BCall led.off()
CCall led.pause()
DCall led.reset()
Which library provides the LED class for Raspberry Pi GPIO control?
Agpiozero
BRPi.GPIO
CwiringPi
DpySerial
Explain how to control an LED connected to a Raspberry Pi using the LED class.
Think about how you tell the Raspberry Pi which pin the LED is on and how you turn it on or off.
You got /3 concepts.
    Describe what happens when you call the blink() method on an LED object without arguments.
    Consider the default behavior of blinking without extra instructions.
    You got /3 concepts.