SBRGB
•
6
All that this example code does is to set the Red LED at 50% brightness. If we
wanted to change it to 25% brightness, we would change line 2 to:
movlw 0x40 ;25% (256/4 = 64 base10 = 40 HEX)
Now imagine that we vary the percentage value in real time using a variable
rather than a constant of 0x40 (HEX numbering system). On top of this, use a
Sine lookup table to produce smooth changes. When we apply these principles
to all three color elements in the LED at random, you get the Super Blinky!
So how would you achieve an orange color with the SBRGB? First you would
figure out what percentage of each color needs to be on to produce orange.
From the choices of Red, Green and Blue, Orange resides somewhere be-
tween Green and Red. Mostly towards Red end. This means Red will be at a
full 100% duty cycle (255), Green will be around 50% (127), and Blue will be off
at 0% (0).
How about a nice violet color?
Off
On
0
255
Time--->
Off
On
0
255
Time--->
Off
On
0
255
Time--->
RED
GREEN
BLUE
255
Time--->
255
Time--->
255
Time--->
Off
On
0
255
Time--->
Off
On
0
255
Time--->
Off
On
0
255
Time--->
RED
GREEN
BLUE
255
Time--->
255
Time--->
255
Time--->