What is PWM and why is it used for LED brightness control?
PWM stands for Pulse Width Modulation. It controls LED brightness by switching the LED on and off very fast. The longer the LED is on compared to off, the brighter it looks.
Click to reveal answer
beginner
How do you set up a GPIO pin on Raspberry Pi for PWM to control an LED?
You first import the GPIO library, set the pin mode to BCM or BOARD, then set the pin as output. After that, you create a PWM instance on that pin with a frequency, and start it with a duty cycle.
Click to reveal answer
beginner
What does the duty cycle in PWM represent?
The duty cycle is the percentage of time the signal is ON during one cycle. For example, 50% means the LED is on half the time and off half the time, making it appear half as bright.
Click to reveal answer
intermediate
Why can't we just use a resistor to change LED brightness instead of PWM?
Using a resistor changes current but wastes power as heat and is less efficient. PWM controls brightness by switching on/off quickly, saving power and allowing smooth brightness control.
Click to reveal answer
beginner
What Python library is commonly used on Raspberry Pi to control GPIO pins for LED brightness?
The RPi.GPIO library is commonly used. It allows you to set up pins, create PWM signals, and control LED brightness easily.
Click to reveal answer
What does PWM stand for in LED brightness control?
APulse Width Modulation
BPower Wave Management
CPulse Wave Measurement
DPower Width Modulation
✗ Incorrect
PWM means Pulse Width Modulation, which controls brightness by changing how long the LED is on in each cycle.
In PWM, what happens if the duty cycle is 100%?
ALED is fully on
BLED is off
CLED blinks slowly
DLED is half bright
✗ Incorrect
A 100% duty cycle means the LED is on all the time, so it is fully bright.
Which Raspberry Pi pin mode can be used to refer to pins by their physical location?
ABCM
BBOARD
CPWM
DGPIO
✗ Incorrect
BOARD mode refers to pins by their physical position on the Raspberry Pi header.
Why is PWM preferred over using a resistor to control LED brightness?
APWM wastes more power
BResistor is more efficient
CPWM allows smooth brightness control and saves power
DResistor changes color
✗ Incorrect
PWM saves power and allows smooth brightness changes by switching the LED on and off quickly.
Which Python command starts PWM on a GPIO pin with a duty cycle of 75%?
AGPIO.output(75)
BGPIO.setup(75)
Cpwm.start(75)
Dpwm.ChangeDutyCycle(75)
✗ Incorrect
The pwm.start(75) command starts PWM with a 75% duty cycle, making the LED 75% bright.
Explain how PWM controls LED brightness on a Raspberry Pi.
Think about how turning the LED on and off quickly changes how bright it looks.
You got /3 concepts.
Describe the steps to set up PWM on a Raspberry Pi GPIO pin to control an LED.
Remember the order of commands to prepare the pin and start PWM.
You got /5 concepts.
Practice
(1/5)
1. What does PWM stand for in the context of controlling LED brightness on a Raspberry Pi?
easy
A. Pulse Wire Mode
B. Power Wave Management
C. Pin Wiring Method
D. Pulse Width Modulation
Solution
Step 1: Understand PWM meaning
PWM is a technique used to control power by switching it on and off quickly.
Step 2: Match PWM to full form
Pulse Width Modulation means changing the width of the pulse to control power, which fits LED brightness control.
Final Answer:
Pulse Width Modulation -> Option D
Quick Check:
PWM = Pulse Width Modulation [OK]
Hint: PWM controls brightness by changing pulse width [OK]
Common Mistakes:
Confusing PWM with power management
Thinking PWM is a wiring method
Mixing up acronyms
2. Which of the following is the correct way to start PWM on GPIO pin 18 with a frequency of 1000 Hz using RPi.GPIO?
easy
A. pwm = GPIO.PWM(18, 1000); pwm.start(0)
B. pwm = GPIO.PWM(18); pwm.start(1000)
C. pwm = GPIO.PWM(1000, 18); pwm.start(0)
D. pwm = GPIO.PWM(18, 0); pwm.start(1000)
Solution
Step 1: Check PWM constructor parameters
RPi.GPIO PWM takes pin number first, then frequency in Hz.
Step 2: Verify start method usage
start() takes initial duty cycle (0-100), so start(0) is correct for off initially.
Final Answer:
pwm = GPIO.PWM(18, 1000); pwm.start(0) -> Option A
Quick Check:
GPIO.PWM(pin, freq) then start(duty) [OK]
Hint: PWM(pin, frequency) then start(duty cycle) [OK]
Common Mistakes:
Swapping frequency and pin
Starting PWM with frequency instead of duty
Using zero frequency
3. What will be the output brightness level of the LED after running this code snippet?