Adafruit NeoPixel
Introduction
In this article we describe the Flora RGB Smart NeoPixel version 2
See also:
The pixel
Main characteristics:
- 12.5mm diameter
- 2.5mm total thickness
- 800 KHz speed protocol
- Chainable design, meaning that you can connect several of these to one pin and chain them
- 5-9VDC power (can run at 3.5V but color will be dimmed), constant current 18.5mA per LED (~55mA max total per pixel)
Hooking up a NeoPixel
According to Hook up alligator clips (retrieved Aug 2019), a NeoPixel must be connected with three wires to a FLORA-type board. Depending on the board, the wiring is bit different. E.g. on a GEMMA, the signal must be wired from A1.
Board | NeoPixel |
---|---|
VOUT
Power output |
+ |
GND
Grounding |
- |
D1 / ~A0
General Purpose Input Ouput |
↑ (arrow pointing towards the inside) |
Board | NeoPixel |
---|---|
VOUT | + |
GND | - |
A1
General Purpose Input Ouput |
↑ (arrow pointing towards the inside) |
MakeCode example for the Circuit Playground Express
This does the following:
- On start, a short animation of 5 seconds of the strip
- After that all turned to black (off)
- Pressing Button A -> All Pixels will be blue
- Pressing Button B -> All Pixels will be red
- Pressing A3 (or the attached copper) band: Three loops that will light up with different colors. After that: all set to yellow
// Button A down input.buttonA.onEvent(ButtonEvent.Down, function () {
// show blue on all pixels strip.setAll(0x0000FF)
}) // Button B down input.buttonB.onEvent(ButtonEvent.Down, function () {
// show red on all pixels strip.setAll(0xFF0000)
}) // A3 touched (you could add a strip of copper) input.touchA3.onEvent(ButtonEvent.Down, function () {
for (let index2 = 0; index2 <= strip.length(); index2++) { strip.setPixelColor(index2, 0xff0000) pause(100) } for (let index22 = 0; index22 <= strip.length(); index22++) { strip.setPixelColor(index22, 0x00ff00) pause(100) } for (let index3 = 0; index3 <= strip.length(); index3++) { strip.setPixelColor(index3, 0x0000ff) pause(100) } for (let index32 = 0; index32 <= strip.length(); index32++) { strip.setPixelColor(index32, 0xffff00) }
}) let strip: light.NeoPixelStrip = null // mount an external Neopixel strip on pin A1 with 30 strip = light.createStrip(pins.A1, 30) // show default animation for 5 seconds strip.showAnimation(light.rainbowAnimation, 5000) // Turn it off (make colors black) for (let index = 0; index <= strip.length(); index++) {
strip.setPixelColor(index, 0x000000)
}
Programming a strand of pixels
This also works with a single pixel...
Links
Official general documentation (read this)
Tutorials