I have one RGB LED (common anode type), and while I can get every color to light up independently I am seeing some bizarre behavior when trying to combine colors. This is my first project involving LEDs, so I am trying to go slow and create a working python script that covers the basics so that I can reference it when working on the bigger build. I would be very grateful if someone could help shed some light on what I'm doing wrong.
The pattern seems to be that when multiple colors are called simultaneously only the first color of the set activates... but I have no idea why. What am I doing wrong here?
Details:
The components involved are:
- Raspberry Pi 3B (running Raspian, latest)
- Rugged Metal Pushbutton w/ RGB LED (common anode, built-in resistors, 3-6V)
The RGB LEDs are attached as follows:
- Red - Pin 11
- Green - Pin 15
- Blue - Pin 13
- C+ - Pin 1 (3.3V)
- pinout quick reference
And the code...
#!/usr/bin/env python
from gpiozero import RGBLED
from time import sleep
led = RGBLED(red="BOARD11", green="BOARD15", blue="BOARD13")
print("Common Anode - Full Red...")
led.color = (0, 1, 1) # full red
sleep(2)
print("Common Anode - Full Green...")
led.color = (1, 0, 1) # full green
sleep(2)
print("Common Anode - Full Blue...")
led.color = (1, 1, 0) # full blue
sleep(2)
print("Common Anode - Magenta (R+B)")
led.color = (0, 1, 0) # magenta
sleep(2)
print("Common Anode - Yellow (R+G)")
led.color = (0, 0, 1) # yellow
sleep(2)
print("Common Anode - Cyan (G+B)")
led.color = (1, 0, 0) # cyan
sleep(2)
print("Common Anode - White (R+G+B)")
led.color = (0, 0, 0) # white
sleep(2)
led.close()
Results:
- Full Red = Full Red (yay!)
- Full Green = Full Green (yay!)
- Full Blue = Full Blue (yay!)
- Magenta (R+B) = Full Red <----- Not Right
- Yellow (R+G) = Full Red <----- Not Right
- Cyan (G+B) = Full Green <----- Not Right
- White (R+B+G) = Full Red <----- Not Right