Complete the code to import the GPIO library.
import [1]
The RPi.GPIO library is used to control GPIO pins on Raspberry Pi.
Complete the code to set the GPIO mode to BCM numbering.
GPIO.setmode([1])Using GPIO.BCM sets the pin numbering to Broadcom SOC channel numbers.
Fix the error in setting up the button pin as input with pull-up resistor.
GPIO.setup(18, [1], pull_up_down=GPIO.PUD_UP)
The button pin must be set as GPIO.IN to read input signals.
Fill both blanks to add an event detect for a falling edge on pin 18 with a callback function.
GPIO.add_event_detect(18, [1], callback=[2])
The event detect should watch for a falling edge (GPIO.FALLING) and call the button_pressed function.
Fill all three blanks to define a callback function that prints 'Button pressed!' when called.
def [1](channel): print([2]) GPIO.add_event_detect(18, GPIO.FALLING, callback=[3])
The function button_pressed is defined to print the message, and then used as the callback.