0
0
Raspberry Piprogramming~5 mins

RPi.GPIO library setup in Raspberry Pi - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aimport RPi.GPIO as GPIO
Bimport gpio
Cimport Raspberry.GPIO
Dimport GPIO
What does GPIO.setmode(GPIO.BCM) specify?
ASet all pins as inputs
BUse physical pin numbers
CUse Broadcom chip pin numbers
DDisable GPIO pins
Which function resets GPIO pins to a safe state?
AGPIO.stop()
BGPIO.reset()
CGPIO.close()
DGPIO.cleanup()
How do you set GPIO pin 17 as an output?
AGPIO.setup(17, GPIO.OUT)
BGPIO.setmode(17, GPIO.OUT)
CGPIO.setup(17, GPIO.IN)
DGPIO.output(17, GPIO.OUT)
Why is it important to call GPIO.cleanup()?
ATo start the GPIO pins
BTo reset pins and avoid errors
CTo install the library
DTo import GPIO functions
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.