Arduino NeoPixel Ring Rainbow: Wiring, Code and Simulator
To build this Arduino NeoPixel Ring Rainbow project you need an Arduino Uno and a NeoPixel ring. A 16-pixel WS2812 ring on pin 6, driven by the Adafruit NeoPixel library. Make the 3 connections in the wiring table, upload the Arduino C++ code, and watch the rainbow chase. Every colour is 24 bits sent down one wire at 800 kHz.
Open this circuit in the free Arduino Uno simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | NeoPixel ring | A ring of WS2812 pixels. DIN from a pin, VCC to 5V, GND to GND. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno pin 6 | NeoPixel ring DIN |
| 2 | Arduino Uno 5V | NeoPixel ring VCC |
| 3 | Arduino Uno GND | NeoPixel ring GND |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add a NeoPixel ring from the parts palette.
- Wire 1. Connect Arduino Uno pin 6 to NeoPixel ring DIN.
- Wire 2. Connect Arduino Uno 5V to NeoPixel ring VCC.
- Wire 3. Connect Arduino Uno GND to NeoPixel ring GND.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- Run it. Press Run. Watch the rainbow chase. Every colour is 24 bits sent down one wire at 800 kHz.
Arduino C++ code
// NeoPixel ring: a rainbow that chases around 16 pixels on pin 6.
#include <Adafruit_NeoPixel.h>
const int PIN = 6;
const int COUNT = 16;
Adafruit_NeoPixel ring(COUNT, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
ring.begin();
ring.setBrightness(80);
}
void loop() {
static uint16_t hue = 0;
for (int i = 0; i < COUNT; i++) {
uint16_t h = hue + i * (65536L / COUNT);
ring.setPixelColor(i, ring.gamma32(ring.ColorHSV(h)));
}
ring.show();
hue += 1024;
delay(20);
}
What to try
Watch the rainbow chase. Every colour is 24 bits sent down one wire at 800 kHz.
Frequently asked questions
How do I wire the NeoPixel Ring Rainbow project on an Arduino Uno?
Make 3 connections: Arduino Uno pin 6 to NeoPixel ring DIN; Arduino Uno 5V to NeoPixel ring VCC; Arduino Uno GND to NeoPixel ring GND.
What parts do I need for this Arduino project?
An Arduino Uno and a NeoPixel ring.
Can I simulate this Arduino project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.
What does the code do?
A 16-pixel WS2812 ring on pin 6, driven by the Adafruit NeoPixel library.
More Arduino Uno projects
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator