What is the main issue causing the LED to not show the mixed color?
medium
A. Calling GPIO.cleanup() immediately stops PWM signals
B. Duty cycle values must be 0 or 100 only
C. PWM frequency is not set before starting
D. Blue LED must be started with 50% duty cycle
Solution
Step 1: Understand GPIO.cleanup() effect
GPIO.cleanup() resets all GPIO pins, stopping PWM signals immediately.
Step 2: Identify timing issue in code
Calling cleanup right after starting PWM stops the LEDs before visible mixing.
Final Answer:
Calling GPIO.cleanup() immediately stops PWM signals -> Option A
Quick Check:
cleanup() stops PWM = A [OK]
Hint: Don't call GPIO.cleanup() before PWM runs [OK]
Common Mistakes:
Thinking duty cycle must be 0 or 100 only
Ignoring cleanup() effect on GPIO pins
Assuming frequency defaults to zero
5. You want to create a smooth color fade from red to blue on an RGB LED using Raspberry Pi PWM. Which approach correctly mixes colors to achieve this effect?
hard
A. Turn off green and blue, then blink red rapidly
B. Keep red at 100 and blue at 100 simultaneously for full brightness
C. Gradually decrease red duty cycle from 100 to 0 while increasing blue from 0 to 100
D. Set all colors to 50% duty cycle and keep constant
Solution
Step 1: Understand color fading by PWM mixing
Fading from red to blue means red brightness decreases while blue brightness increases smoothly.
Step 2: Apply PWM duty cycle changes
Decrease red duty cycle from 100% to 0%, increase blue from 0% to 100%, green stays off.
Final Answer:
Gradually decrease red duty cycle from 100 to 0 while increasing blue from 0 to 100 -> Option C
Quick Check:
Fade red down, blue up = A [OK]
Hint: Fade one color down, other up for smooth transition [OK]
Common Mistakes:
Turning both colors fully on causes white, not fade
Blinking one color doesn't create smooth fade
Keeping all colors constant prevents fading
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.