![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Demo of NeoPixels using buffer/array of pixels method.
Dependencies: PixelArrayBuffer mbed
Edit of Jacob Bramley's original NeoPixel Demo code. https://developer.mbed.org/users/JacobBramley/code/NeoPixel-Demo/ This code simply demos the buffer/array of pixels method in updating the NeoPixel chain. The original version of this code used the generator method.
Diff: main.cpp
- Revision:
- 0:69bfb2320a83
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 10 06:26:24 2015 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" +#include "neopixel.h" + +// This must be an SPI MOSI pin. +#define DATA_PIN p5 + + +int main() +{ + + + // Create a temporary DigitalIn so we can configure the pull-down resistor. + // (The mbed API doesn't provide any other way to do this.) + // An alternative is to connect an external pull-down resistor. + DigitalIn(DATA_PIN, PullDown); + + // The pixel array control class. + neopixel::PixelArray array(DATA_PIN); + // Declare array/buffer of type Pixel. + uint16_t numPixels = 4; + neopixel::Pixel pixels[numPixels]; + // Use buffer method of updating pixels. + pixels[0].red = 255; + pixels[0].green = 0; + pixels[0].blue = 0; + pixels[1].red = 255; + pixels[1].green = 140; + pixels[1].blue = 0; + pixels[2].red = 0; + pixels[2].green = 255; + pixels[2].blue = 0; + pixels[3].red = 0; + pixels[3].green = 0; + pixels[3].blue = 255; + while (1) { + array.update(pixels, numPixels); + + } +} \ No newline at end of file