Blink
Here is one of simplest moving rainbow programs. It is our version of "Hello World!.
Our first program will just blink the first pixel on and off every 1/2 second.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Exercises
Change the Color Lab
- Change the line:
strip[0] = (255,0,0)
to be:
strip[0] = (0,255,0)
What happens?
Change the Position Lab
- Change the line:
strip[0] = (255,0,0)
to be:
strip[1] = (255,0,0)
What happens?
Change the Sleep Time
What happens if you change the sleep time?
from:
sleep(.5)
to:
sleep(.1)
What is the smallest time you can use and still see flashing? Hint: Try values like .05
, or .005
RGB Lab
- Change the line:
strip[0] = (255,0,0)
to be:and change the1 2 3
strip[0] = (255,0,0) strip[1] = (0,255,0) strip[2] = (0,0,255)
1 2 3
strip[0] = (0,0,0) strip[1] = (0,0,0) strip[2] = (0,0,0)
What happened?
Why Do We Need Strip.Write?
Try to remove one of the line that does strip.write(). What happens? Why do you think we need this line?
LED Strip State
What happens if you stop the program when the LED strip LEDs are on?
On Your Own
What if you extended the lab to more positions and colors?