User Manual

57
R_val = MAP(R_val, 0, 255, 0, 100) # use map function to map the R,G,B
value among 0~255 into PWM value among 0-100.
G_val = MAP(G_val, 0, 255, 0, 100)
B_val = MAP(B_val, 0, 255, 0, 100)
p_R.ChangeDutyCycle(R_val) # Assign the mapped duty cycle value to the
corresponding PWM channel to change the luminance.
p_G.ChangeDutyCycle(G_val)
p_B.ChangeDutyCycle(B_val)
for color in COLOR: # Assign every item in the COLOR list to the color
respectively and change the color of the RGB LED via the setColor() function.
setColor(color) # change the color of the RGB LED
time.sleep(0.5) # set delay for 0.5s after each color changing. Modify this
parameter will changed the LED’s color changing rate.
Here you should see the RGB LED flash different colors in turn.
Further Exploration
You can modify the parameters of the function ledColorSet( ) by yourself, and then and
run the code to see the color changes of the RGB LED.
SunFounder