Pre-requisites:
Install
sudo apt-get updatesudo apt-get install pigpio python-pigpio python3-pigpio
Program:
Simple program to control a SMD5050 Led Stripimport timeimport pigpioimport random#the pin code uses the BCM numberv_pinG = 14 #GREENv_pinR = 15 #REDv_pinB = 23 #BLUEv_pio = pigpio.pi()#routinesdef SetLed(v_gpio, value):v_pio.set_PWM_dutycycle(v_gpio, value)print("Led: ", v_gpio, "Value:", value)def InitLed():SetLed(v_pinR, 0)SetLed(v_pinG, 0)SetLed(v_pinB, 0)def TestColor(v_color):for i in range(255):SetLed(v_color, i)time.sleep(0.025)#turn off lightsInitLed()#test colorsTestColor(v_pinR)TestColor(v_pinG)TestColor(v_pinB)input("Press a Ley to start random colors")#random colors until keyboard interuptiontry:while True:v_value = random.randint(1,255)SetLed(v_pinR, v_value)v_value = random.randint(1,255)SetLed(v_pinG, v_value)v_value = random.randint(1,255)SetLed(v_pinB, v_value)time.sleep(0.2)except KeyboardInterrupt:print("Aborting program")pass#turn off lightsInitLed()#end programv_pio.stop()