0
0
Raspberry Piprogramming~5 mins

Digital input (GPIO.input) in Raspberry Pi - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does GPIO.input(pin) do in Raspberry Pi programming?
It reads the current digital value (HIGH or LOW) from the specified GPIO pin, telling you if the pin is receiving voltage or not.
Click to reveal answer
beginner
Why do you need to set up a GPIO pin as input before using GPIO.input()?
Because the Raspberry Pi needs to know if the pin is used to read signals (input) or send signals (output). Setting it as input prepares it to detect voltage changes.
Click to reveal answer
beginner
What are the possible return values of GPIO.input(pin)?
It returns either GPIO.HIGH (or 1) if voltage is detected, or GPIO.LOW (or 0) if no voltage is detected.
Click to reveal answer
intermediate
How can you use GPIO.input() to detect a button press?
Connect the button to a GPIO pin set as input. When pressed, the pin reads HIGH or LOW depending on wiring. Use GPIO.input(pin) to check if the button is pressed.
Click to reveal answer
intermediate
What is a pull-up or pull-down resistor and why is it important when using GPIO.input()?
Pull-up or pull-down resistors keep the input pin at a known voltage level (HIGH or LOW) when no button is pressed, preventing random noise from causing false readings.
Click to reveal answer
What must you do before reading a pin with GPIO.input(pin)?
ANothing, just read directly
BSet the pin as output using <code>GPIO.setup(pin, GPIO.OUT)</code>
CCall <code>GPIO.output(pin, True)</code>
DSet the pin as input using <code>GPIO.setup(pin, GPIO.IN)</code>
What does GPIO.input(pin) return if the pin voltage is LOW?
AGPIO.HIGH
BAn error
CGPIO.LOW
DNone
Why use a pull-down resistor with a button input?
ATo keep the pin voltage LOW when button is not pressed
BTo keep the pin voltage HIGH when button is not pressed
CTo increase voltage
DTo power the button
If GPIO.input(pin) returns 1, what does it mean?
APin is HIGH
BPin is LOW
CPin is broken
DPin is not set up
Which Python library is commonly used for GPIO input on Raspberry Pi?
Apandas
BRPi.GPIO
Cmatplotlib
Dnumpy
Explain how to read a button press using GPIO.input on a Raspberry Pi.
Think about wiring and reading the pin state.
You got /4 concepts.
    Describe why pull-up or pull-down resistors are important when using digital inputs.
    Imagine a wire not connected to anything.
    You got /3 concepts.