JS 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 the connected LED, BrainPad holds the color state for each LED in its internal memory.

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

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

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 send the data right to the LEDs, and it does them all at once. The Show() function is not needed with SetMultiple().


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!