NeoPixel LEDs
NeoPixels:
.
Spirit has 27 NeoPixel LEDs that can individually be set to any color. Each pixel can be controlled individually by number, or by the use of functions that set groups of pixels to different colors. Each pixel actually contains three individual lights - one each of red, green, and blue. Each of these red, green, and blue parameters of each pixel can be set individually. By mixing different values almost any color can be created. By setting each red, green, and blue to the same amount, white color is created.
The pixels are addressed as follows:
0 Center pixel in middle of Spirit Main Board 1 Left Eye 2 Right Eye 3~14 Left Wing Pixels 15~26 Right Wing Pixels
Each pixel, or group of pixels is adjusted by setting each of the red, green, and blue elements of each pixel to a value between 0 and 255, with zero being completely off, and 255 being maximum bright.
Important Notes:
These pixels are extremely bright. It generally is not necessary to set the pixels anywhere near maximum brightness. Normally values of 150 or so make the pixels appear very bright. There is no harm in using larger values, but know the pixels will consume much more power (shorter battery life) at the brighter values.
At maximum brightness, full white (all values set to 255), each pixel will draw about 60 milliamps.
Setting all pixels to max bright full white will draw about 60 ma * 27 pixels = 1,620 milliamps (which is 1.6 amps). The maximum current draw of the entire robot is about 2000 milliamps - much more than this will cause the robot to power off due to over-current. This won't damage anything, but be aware of this if the robot is powering off while you're making the LEDs very bright. Remember the Raspberry Pi will draw about 300 to 500 milliamps idling, and each motor will draw about 60 milliamps when running. Servo movement causes spikes above this as well, so it is possible to cause an over-current shutdown of the robot when using lots of pixels at maximum brightness.
At more "normal" levels, where pixels are various colors (so all elements aren't on at once) and at more normal brightness levels, each pixel will draw an average of 5 to 20 milliamps.
.
setPixelRGB();
setPixelRGB(pixelAddress, redValue, greenValue, blueValue); //controls a specific pixel to a specific color
setPixelRGB(0, 0, 50, 0); //make center pixel on main board green, 50 brightness value
setPixelRGB(0, 70, 0, 70); //make center pixel on main board purple (red+blue), 70 brightness value
setPixelRGB(3, 70, 0, 70); //make first pixel on left wing purple (red+blue), 70 brightness value
This is the primary function used to control individual pixels. The function accepts four values. The first is the address of the pixel you are controlling, and the second, third, and fourth values are the red, green, and blue values for the pixel. It can be used in loops as well to iterate through different pixels to set many to different values. Turn off any given pixel by setting the red, green, and blue values to zero.
.
setAllPixelsRGB();
setAllPixelsRGB(redValue, greenValue, blueValue); //sets all pixels to a specific color
setAllPixelsRGB(0, 50, 0); //make all pixels green, 50 brightness value
setAllPixelsRGB(0, 0, 0); //turn off all pixels
This is a function to easily set all pixels on the robot to a specific color. Setting all pixels to zero values is an easy way to turn off all pixels. Be aware that setting all pixels to a high brightness setting will draw higher current from the battery. Keep the important notes above in mind.
.
eyesOn();
eyesOn(redValue, greenValue, blueValue); //sets both eyes to a specific color
eyesOn(0, 50, 0); //make both eyes green, 50 brightness value
eyesOn(70, 0, 70); //make both eyes purple (red+blue), 70 brightness value
eyesOn(0, 0, 0); //turn off both eyes
This is a quick function to set both eyes to the same color.
.
eyesOff();
eyesOff(); //turn off both eyes
This is a quick function to turn off both eyes.
.
rightEye();
rightEye(redValue, greenValue, blueValue); //sets right eye to a specific color
rightEye(0, 50, 0); //make right eye green, 50 brightness value
rightEye(0, 0, 0); //turn off right eye
This is a quick function to set right eye to a specific color.
.
leftEye();
leftEye(redValue, greenValue, blueValue); //sets left eye to a specific color
leftEye(0, 50, 0); //make left eye green, 50 brightness value
leftEye(0, 0, 0); //turn off left eye
This is a quick function to set left eye to a specific color.
.
rightWing();
rightWing(redValue, greenValue, blueValue); //sets all pixels on wing to specific color
rightWing(0, 50, 0); //make all pixels on right wing green, 50 brightness value
rightWing(0, 0, 0); //turn off all pixels on right wing
This is a quick function to set all the pixels on the right wing to a specific color.
.
leftWing();
leftWing(redValue, greenValue, blueValue); //sets all pixels on wing to specific color
leftWing(0, 50, 0); //make all pixels on left wing green, 50 brightness value
leftWing(0, 0, 0); //turn off all pixels on left wing
This is a quick function to set all the pixels on the left wing to a specific color.
.
Last updated
Was this helpful?