NeoPixel

NeoPixel

These addressable (smart) LEDs are very common. Using a single pin, hundreds of LEDs can be set to any color. Those smart LEDs have a small processor (WS2812) built inside of them. An incoming digital signal sets each LED to a specific color. This way, several LEDs can be controlled using a single pin.

When the user sets the color to one of the connected LEDs, BrainPad holds the color state for each LED in its internal memory.

Python

BrainPad.Neo.SetColor(2,0xFF0000)

C#

BrainPad.Neo.SetColor(2,0xFF0000);

JS

await BrainPad.Neo.SetColor(2,0xFF0000);

When ready, all LEDs can be updated at once using Neo.Show(). This function needs to know the pin to send the data to and how many LEDs to update, pin 1 with 8 LEDs in this example.

Python

BrainPad.Neo.Show(1, 8)

C#

BrainPad.Neo.Show(1, 8);

JS

await BrainPad.Neo.Show(1, 8);

To determine the color value, use search the web for “Color picker” and use the hex value. Note that the websites use # to mark a hex value, but in coding, we typically use 0x.

Set Multiple

For applications that require speed. The provided Neo.SetMultiple() method that sends the data right to the LEDs, and it does them all at once. The Show() function is not needed with SetMultiple().

Python

colors = [0] * 8
colors[0] = 0xFF0000
colors[3] = 0x00FF00
BrainPad.Neo.SetMultiple(1, colors)

C#

uint[] colors = new uint[8];
colors[0] = 0xFF0000;
colors[3] = 0x00FF00;
BrainPad.Neo.SetMultiple(1, colors);

JS


uint[] colors = new uint[8];
colors[0] = 0xFF0000;
colors[3] = 0x00FF00;
await BrainPad.Neo.SetMultiple(1, colors);

BrainStorm

How small can a processor be? We are now talking about a processor that is smaller than an ant! Here is a fun fact, a processor is usually smaller than the packaging around it. The packaging is made larger so it can be handled easier.

Content Licensing
Newsletter

Twitter Feed
Hot off the press!