blocks / nano-neopixel-stick
Rainbow on a NeoPixel stick
An Arduino Nano drives an 8-pixel NeoPixel stick through a 470 ohm resistor on DIN. The sketch lights a rainbow.
on Nano (CH340 clone)4 parts1 test
orbe add nano-neopixel-stick
Loading the Block
An Arduino Nano drives an 8-pixel NeoPixel stick through a 470 ohm resistor on DIN. The sketch lights a rainbow.
firmware/rainbow/rainbow.ino 217 BRaw
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUMPIXELS 8
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.rainbow();
strip.show();
}
void loop() {
}
scene.jsonc 1.0 kBRaw
// A Nano drives an 8-pixel NeoPixel stick. The Nano straddles the centre channel over
// columns 1 to 15. D6 is column 7 on the f to j side. The stick's header is GND, 5V, DIN
// across the board width, so the stick turns a quarter turn and hangs off the a side,
// in a18, a19 and a20.
{
"format": 1,
"parts": {
"bb": { "type": "breadboard-400" },
"nano": { "type": "nano-board", "firmware": "build/rainbow.ino.hex" },
"r1": { "type": "resistor-axial", "resistance": "470" },
"stick": { "type": "neopixel-stick-8" },
},
"layout": {
"bb": { "at": [0, 0, 0] },
"nano": { "on": { "D13": "bb.d1" } },
"r1": { "on": { "a": "bb.j16" } }, // b in column 20
"stick": { "on": { "GND": "bb.a18" }, "rotate": [0, 0, -90] }, // 5V in a19, DIN in a20
},
"nets": { "GND": "nano.GND" },
"wires": [
["bb.j7", "bb.f16"], // D6 to r1.a
["bb.f20", "bb.b20"], // r1.b to stick.DIN
["bb.a12", "bb.b19"], // 5V to stick.5V
["bb.a14", "bb.b18"], // GND to stick.GND
],
}
tests/rainbow.test 377 BRaw
# strip.rainbow() latches one colour on each pixel, and the chain keeps them apart. open step 20ms expect @stick.px1 rgb(255,0,0) expect @stick.px2 rgb(255,120,0) expect @stick.px3 rgb(42,255,0) expect @stick.px4 rgb(0,255,7) expect @stick.px5 rgb(0,255,255) expect @stick.px6 rgb(0,7,255) expect @stick.px7 rgb(42,0,255) expect @stick.px8 rgb(255,0,120) expect no diagnostics
orbe add writes these files.
How it works
The sketch calls strip.rainbow() on an 8-pixel stick wired to D6, then show(). A 470 ohm resistor sits between D6 and DIN. Each pixel keeps its own colour.
Check it with orbe check scene.jsonc and run its tests with orbe test.
Parts in this circuit
- nanoNano (CH340 clone)rainbow.ino.hex
- r1Resistor, 1/4 W axial470 Ω
License and files(MIT OR Apache-2.0) AND LGPL-2.1-or-later AND LGPL-3.0-or-later
| File | Size |
|---|---|
| README.md | 267 B |
| block.jsonc | 506 B |
| build/rainbow.ino.hex | 8.7 kB |
| firmware/LICENSE-libc | 2.5 kB |
| firmware/LICENSE-neopixel | 7.7 kB |
| firmware/LICENSE-runtime | 26.4 kB |
| firmware/NOTICE | 2.2 kB |
| firmware/rainbow/rainbow.ino | 217 B |
| scene.jsonc | 1.0 kB |
| tests/rainbow.test | 377 B |