0
0
Raspberry Piprogramming~20 mins

Raspberry Pi hardware overview (GPIO, USB, HDMI) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Raspberry Pi Hardware Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
GPIO Pin State Reading

What is the output of this Python code snippet that reads a GPIO pin state on a Raspberry Pi?

Raspberry Pi
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
state = GPIO.input(18)
print(state)
AGPIO.IN
B1
C0
DRaises RuntimeError
Attempts:
2 left
💡 Hint

Consider the pull-up resistor setting and what it means for the input pin state when nothing is connected.

🧠 Conceptual
intermediate
1:30remaining
USB Port Power Limits

Which statement correctly describes the power limits of USB ports on a Raspberry Pi 4?

AAll USB ports share a total current limit of 1.2A combined.
BEach USB port can supply up to 1.2A independently.
CUSB ports do not supply power, only data signals.
DEach USB port can supply up to 500mA independently.
Attempts:
2 left
💡 Hint

Think about the total power budget for USB devices connected to the Pi.

Predict Output
advanced
2:00remaining
HDMI Display Resolution Detection

What will this Python code print when run on a Raspberry Pi connected to a 1920x1080 HDMI display?

Raspberry Pi
import subprocess
output = subprocess.run(['tvservice', '-s'], capture_output=True, text=True)
print(output.stdout.strip())
AError: tvservice command not found
Bstate 0x40001 [LCD], 800x480 @ 60.00Hz, progressive
Cstate 0x12000a [HDMI DMT (82) RGB full 16:9], 1280x720 @ 60.00Hz, progressive
Dstate 0x12000a [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive
Attempts:
2 left
💡 Hint

Look for the resolution and refresh rate in the output string.

🔧 Debug
advanced
1:30remaining
Fixing GPIO Output Code

What error does this code raise when trying to set a GPIO pin high on a Raspberry Pi?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, 2)
ARuntimeError: GPIO not set up
BTypeError: GPIO.output() takes 2 positional arguments but 3 were given
CValueError: The GPIO pin value must be 0 or 1
DNo error, pin set high
Attempts:
2 left
💡 Hint

Check the allowed values for GPIO.output() when setting pin state.

🚀 Application
expert
2:00remaining
Calculate Total GPIO Pins Available

How many general-purpose input/output (GPIO) pins are available on a Raspberry Pi 4 Model B for user programming?

A26 pins
B40 pins
C28 pins
D17 pins
Attempts:
2 left
💡 Hint

Consider the total pins on the header and which are reserved for power or ground.