Recall & Review
beginner
What is the purpose of the RPi.GPIO library in Raspberry Pi?
The RPi.GPIO library allows you to control the Raspberry Pi's GPIO pins to interact with electronic components like LEDs, buttons, and sensors.
Click to reveal answer
beginner
How do you import the RPi.GPIO library in a Python script?You import it using <code>import RPi.GPIO as GPIO</code>. This lets you use the GPIO functions with the short name <code>GPIO</code>.Click to reveal answer
beginner
What does
GPIO.setmode(GPIO.BCM) do?It sets the pin numbering system to BCM, which means you refer to the GPIO pins by their Broadcom chip numbers.
Click to reveal answer
beginner
Why should you call
GPIO.cleanup() at the end of your program?Calling
GPIO.cleanup() resets the GPIO pins to a safe state, preventing issues when you run other programs later.Click to reveal answer
beginner
How do you set a GPIO pin as an output using RPi.GPIO?
Use
GPIO.setup(pin_number, GPIO.OUT) to set a pin as an output so you can control devices like LEDs.Click to reveal answer
Which command imports the RPi.GPIO library correctly?
✗ Incorrect
The correct import statement is
import RPi.GPIO as GPIO to access GPIO functions.What does
GPIO.setmode(GPIO.BCM) specify?✗ Incorrect
It sets the pin numbering to Broadcom chip numbers (BCM), not physical pin numbers.
Which function resets GPIO pins to a safe state?
✗ Incorrect
GPIO.cleanup() resets pins to avoid conflicts in future programs.How do you set GPIO pin 17 as an output?
✗ Incorrect
Use
GPIO.setup(17, GPIO.OUT) to configure pin 17 as output.Why is it important to call
GPIO.cleanup()?✗ Incorrect
Calling
GPIO.cleanup() resets pins to prevent errors in later use.Explain the steps to set up the RPi.GPIO library for controlling an LED on a Raspberry Pi.
Think about how you prepare the pins and clean up after.
You got /5 concepts.
Why do we choose between BCM and BOARD modes in RPi.GPIO, and what is the difference?
Consider how you identify pins on the Raspberry Pi.
You got /4 concepts.