I found a python script to control an RGB LED with GPIO output pins from a raspberry. I connected a common cathode LED to the GPIO Pins and added a 300 ohm resistor to the ground pin. When I run the script it works quite well. I can choose the RGB values with an input in the terminal python led.py 0 100 110
for example. As long as I choose 255 0 0 - 0 255 0 - 0 0 255 it works perfectly fine. The strange thing is that when I choose for a mix of values python led.py 0 20 20
and run the code the LED starts shining. However it looks like there's a delay between de colors (red, green, blue) that are displayed, so I can sort of see how the colours are mixed. I found this very weird because I don't really use delays in my script. Someone an idea?
UPDATE: when I remove the resistor and connect the ground directly I dont get the flicker, problem is: my pcb is set in this configuration. as soon as I add a resistor for example 15 ohm I get the flicker back
I posted a video so you can see it https://www.youtube.com/watch?v=N6J5zy38j38, no it's not my camera ;)
#! /usr/bin/env python
import RPi.GPIO as GPIO
import sys
import time
# RGB LED pinnen configureren.
pinRood = 17
pinGroen = 27
pinBlauw = 22
# GPIO setup.
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Zet de GPIO pinnen als uitgang.
GPIO.setup(pinRood, GPIO.OUT)
GPIO.setup(pinGroen, GPIO.OUT)
GPIO.setup(pinBlauw, GPIO.OUT)
# Gebruik PWM op de pinnen.
ROOD = GPIO.PWM(pinRood, 1000)
GROEN = GPIO.PWM(pinGroen, 1000)
BLAUW = GPIO.PWM(pinBlauw, 1000)
ROOD.start(0)
GROEN.start(0)
BLAUW.start(0)
if len(sys.argv) > 3:
while True:
# converteer de waarde 255 tot max 100 voor PWM.
roodwaarde = (int(sys.argv[1]) * 100) / 255
groenwaarde = (int(sys.argv[2]) * 100) / 255
blauwwaarde = (int(sys.argv[3]) * 100) / 255
ROOD.ChangeDutyCycle(roodwaarde)
GROEN.ChangeDutyCycle(groenwaarde)
BLAUW.ChangeDutyCycle(blauwwaarde)
GPIO.cleanup()