
1
SKILL
LEVEL
Ringo Educational Guide Rev04.1 ~ Plum Geek
Using Ringo’s Color Lights
void loop(){
SetPixelRGB( 3, 0, 0, 200); //set pixel 3 to 0 red, 0 green, and 200 blue
}
Lets see if we can make the light on the top of Ringo’s body turn blue. You’ll be
writing most of your code inside the
void loop(){
function (at least until you start
writing your own functions!). Make your
void loop()
function look like this:
Now try to compile and load this code onto your Ringo. About a second after you
turn on the power switch, the light on the front top of Ringo’s body should be bright
blue. Now let’s talk about what happened, and why.
The
SetPixelRGB()
is taking four numbers, called “arguments” which control what
the function does. The first number, in this case “3” tells Ringo’s brain to target the
pixel at address “3”. The next three numbers tell the pixel at address 3 how bright
to turn on the red, green, and blue lights inside the pixel. In this case, the red is
set to 0 so it won’t be on at all, as well as the green will be set to 0 so it won’t be
on either. The last number is 200, which corresponds to the blue led which will be
turned on at a brightness of 200, which as you can see, is pretty bright!
If you have trouble remembering the address of each pixel, note that the address is
printed on Ringo’s circuit board right next to the light. You may also refer to each
pixel by using key words as follows:
You can use the key word interchanably with the pixel address when calling the
SetPixelRGB() function. Like this:
EYE_LEFT
//Pixel 5
EYE_RIGHT
//Pixel 4
BODY_TOP
//Pixel 3
BODY_BOTTOM
//Pixel 2
TAIL_TOP
//Pixel 0
TAIL_BOTTOM
//Pixel 1
SetPixelRGB( 3, 0, 0, 200);
//this code is the same
SetPixelRGB( BODY_TOP, 0, 0, 200); //as this code