Which of the following is the correct syntax to create an LED object on GPIO pin 17 using gpiozero?
easy📝 Syntax Q3 of 15
Raspberry Pi - gpiozero Library
Which of the following is the correct syntax to create an LED object on GPIO pin 17 using gpiozero?
Aled = LED(17)
Bled = LED(pin_factory=17)
Cled = gpiozero.LED(17)
Dled = LED(GPIO17)
Step-by-Step Solution
Solution:
Step 1: Recall gpiozero LED creation syntax
The LED class is imported and instantiated by passing the pin number directly.
Step 2: Check options
led = LED(17) uses correct syntax: led = LED(17). led = LED(pin_factory=17) uses an unsupported keyword argument. led = gpiozero.LED(17) is incorrect without import prefix. led = LED(GPIO17) uses undefined GPIO17.
Final Answer:
led = LED(17) -> Option A
Quick Check:
LED creation syntax = D [OK]
Quick Trick:Create LED with LED(pin_number) [OK]
Common Mistakes:
Using keyword arguments not supported
Not importing LED before use
Using undefined constants like GPIO17
Master "gpiozero Library" in Raspberry Pi
9 interactive learning modes - each teaches the same concept differently