0
0
Raspberry Piprogramming~20 mins

Why LED and button projects build hardware confidence in Raspberry Pi - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Hardware Confidence Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why do LED projects help beginners understand hardware?
Which of the following best explains why working with LEDs helps beginners build hardware confidence?
ALEDs consume a lot of power, so beginners learn about power management.
BLEDs require complex wiring, which teaches advanced circuit design.
CLEDs provide immediate visual feedback, making it easy to see if the circuit and code work correctly.
DLEDs automatically fix wiring mistakes, reducing errors.
Attempts:
2 left
💡 Hint
Think about how beginners can quickly tell if their setup is correct.
🧠 Conceptual
intermediate
1:30remaining
How do button projects improve hardware skills?
Why do button projects help learners understand hardware better?
AButtons eliminate the need for wiring.
BButtons automatically generate code for the user.
CButtons consume less power than LEDs, so they are safer.
DButtons teach how to read input signals and handle physical interaction with the device.
Attempts:
2 left
💡 Hint
Think about what happens when you press a button in a circuit.
Predict Output
advanced
2:00remaining
What is the output when pressing the button in this Raspberry Pi code?
Given the code below, what will be printed when the button connected to GPIO 17 is pressed?
Raspberry Pi
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)

try:
    while True:
        if GPIO.input(17) == GPIO.LOW:
            print('Button Pressed')
            time.sleep(0.5)
except KeyboardInterrupt:
    GPIO.cleanup()
AButton Pressed
BGPIO Error
CButton Released
DNo output
Attempts:
2 left
💡 Hint
Check what GPIO.LOW means for a button with pull-up resistor.
Predict Output
advanced
2:00remaining
What will the LED do in this Raspberry Pi script?
Consider this code controlling an LED on GPIO 18. What will the LED do when the script runs?
Raspberry Pi
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)

for i in range(3):
    GPIO.output(18, GPIO.HIGH)
    time.sleep(1)
    GPIO.output(18, GPIO.LOW)
    time.sleep(1)

GPIO.cleanup()
AThe LED will stay on continuously.
BThe LED will blink on and off 3 times, each state lasting 1 second.
CThe LED will stay off continuously.
DThe code will raise a runtime error.
Attempts:
2 left
💡 Hint
Look at the loop and the sleep times.
🔧 Debug
expert
2:30remaining
Why does this Raspberry Pi button code fail to detect presses?
This code is supposed to print 'Pressed' when the button is pressed, but it never prints anything. What is the cause?
Raspberry Pi
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)

while True:
    if GPIO.input(17) == GPIO.LOW:
        print('Pressed')
        time.sleep(0.5)
AThe button pin lacks a pull-up or pull-down resistor, causing floating input.
BThe GPIO mode is set incorrectly; it should be BOARD instead of BCM.
CThe time.sleep(0.5) is too short to detect the press.
DThe print statement is inside the loop, causing too many prints.
Attempts:
2 left
💡 Hint
Think about what happens to input pins without pull resistors.