NeoPixel

Up to 4 addressable LED strips — buffered pixel changes, brightness control, and throttled updates for smooth animation.

Requires the Adafruit NeoPixel library and <PardaloteNeoPixel.h> in the sketch. Examples assume:

JS
arduino.add('strip', new NeoPixel());

init()

Initialises the strip. Call inside on('ready').

arduino.strip.init(pin, numPixels, [type])
Parameter Type Description
pin number | string Data pin the strip is wired to.
numPixels number Number of LEDs on the strip.
type constant Optional. Colour order + speed, e.g. NEO_GRB + NEO_KHZ800 (the default, right for most WS2812B strips).
JS
Example — init two strips
arduino.strip.init(6, 30);                     // pin 6, 30 pixels
arduino.strip.init(7, 16, NEO_GRB + NEO_KHZ800);

setPixelColor()

Sets one pixel in the local buffer. Nothing reaches the LEDs until show().

arduino.strip.setPixelColor(index, r, g, b, [w])
Parameter Type Description
index number Pixel index, 0-based.
r, g, b number Colour components, 0–255.
w number Optional white channel (RGBW strips).

Also accepts a packed colour: setPixelColor(index, color).

Color()

Packs r, g, b into a single 32-bit colour value.

arduino.strip.Color(r, g, b)
JS
Example — pack a colour
let red = arduino.strip.Color(255, 0, 0);
arduino.strip.setPixelColor(0, red);

fill()

Fills the whole strip, or a range, with one colour (buffered).

arduino.strip.fill(color, [first], [count])
Parameter Type Description
color number Packed colour from Color().
first number Optional. First pixel to fill.
count number Optional. Number of pixels to fill.
JS
Example — fill a range
arduino.strip.fill(red);          // entire strip
arduino.strip.fill(red, 0, 10);   // pixels 0–9

clear()

Sets all pixels to off (buffered).

arduino.strip.clear()

setBrightness()

Global brightness scale.

arduino.strip.setBrightness(level)
Parameter Type Description
level number 0–255. Default 255 — strips vary, start lower.

show()

Sends the buffered changes to the LEDs. Debounced: rapid draw-loop calls coalesce into a single send (the latest pending state wins).

arduino.strip.show()

getPixelColor() / numPixels()

Reading back the local buffer.

arduino.strip.getPixelColor(index) · arduino.strip.numPixels()

Returns a 32-bit packed colour / the pixel count.

setWriteThreshold()

Pixel changes below the colour distance threshold are ignored — useful for animation loops that might send identical values.

arduino.strip.setWriteThreshold(distance)
Parameter Type Description
distance number Minimum colour distance to count as a change. Default 5.

setWriteThrottle()

Minimum time between show() flushes. Default 20 ms (~50 Hz max). Raise it if you see queue-buildup lag on a slow link; set 0 to disable debouncing.

arduino.strip.setWriteThrottle(ms)
JS
Example — tune the flush rate
arduino.strip.setWriteThrottle(50);  // gentler on the UNO R4's WiFi
arduino.strip.setWriteThrottle(0);   // every show() flushes

Type constants

JS
// Colour order
NEO_RGB   NEO_RBG   NEO_GRB   NEO_GBR   NEO_BRG   NEO_BGR

// Speed
NEO_KHZ800  // most strips (default)
NEO_KHZ400  // older strips

// Combine:
arduino.strip.init(6, 30, NEO_GRB + NEO_KHZ800);
arduino.strip.getState()

Returns a snapshot of all strip state.

See also: NeoPixel example · Troubleshooting