Complete the code to import the GPIO library.
import [1] as GPIO
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 pin 18 as output.
GPIO.setup(18, [1])
To control an LED or output device, the pin must be set as GPIO.OUT.
Fill both blanks to create a Flask route that turns the LED on.
from flask import Flask, [1] app = Flask(__name__) @app.route('/led/on') def led_on(): GPIO.output(18, [2]) return 'LED is ON'
The Flask request module is commonly imported for routes, and GPIO.HIGH turns the LED on.
Fill all three blanks to complete the Flask app that controls the LED state based on URL parameter.
from flask import Flask, request app = Flask(__name__) @app.route('/led/<state>') def led_control(state): if state == '[1]': GPIO.output(18, [2]) else: GPIO.output(18, [3]) return f'LED turned {state}'
The URL parameter state is checked for 'on' to set the pin HIGH; otherwise, it sets LOW to turn off the LED.
