Complete the code to turn on the LED connected to GPIO pin 17.
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.OUT) GPIO.output(17, [1])
Setting GPIO.output to True turns the LED on.
Complete the code to make the LED blink once with a 1 second delay.
import time GPIO.output(18, True) time.sleep([1]) GPIO.output(18, False)
Using 1 second delay makes the LED stay on for 1 second before turning off.
Fix the error in the code to blink the LED 3 times with 0.5 second intervals.
for i in range(3): GPIO.output(22, [1]) time.sleep(0.5) GPIO.output(22, False) time.sleep(0.5)
GPIO.output needs True to turn the LED on inside the loop.
Fill both blanks to create a dictionary mapping LED pins to their on/off status for a pattern.
led_pattern = {17: [1], 27: [2]The pattern turns on LED at pin 17 (True) and turns off LED at pin 27 (False).
Fill all three blanks to create a loop that cycles LEDs on pins 5, 6, and 13 on and off with 0.3 second delay.
pins = [5, 6, 13] for pin in pins: GPIO.output(pin, [1]) time.sleep([2]) GPIO.output(pin, [3])
The loop turns each LED on (True), waits 0.3 seconds, then turns it off (False).
