Arduino FastLED WS2812 Ring: Wiring, Code and Simulator
To build this Arduino FastLED WS2812 Ring project you need an Arduino Uno and a NeoPixel ring. FastLED paints a 16-pixel WS2812 ring by quarters. Make the 3 connections in the wiring table, upload the Arduino C++ code, and replace the colours with CHSV(i * 16, 255, 255) for a rainbow.
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. Replace the colours with CHSV(i * 16, 255, 255) for a rainbow.
Arduino C++ code
// FastLED: paint a 16-pixel WS2812 ring on pin 6, a colour per quarter.
#include <FastLED.h>
#define NUM 16
CRGB leds[NUM];
void setup() {
FastLED.addLeds<WS2812B, 6, GRB>(leds, NUM);
for (int i = 0; i < NUM; i++) {
leds[i] = i < 4 ? CRGB(255, 0, 0) : i < 8 ? CRGB(0, 255, 0) : i < 12 ? CRGB(0, 0, 255) : CRGB(255, 255, 255);
}
FastLED.setBrightness(255);
FastLED.show();
}
void loop() {}
What to try
Replace the colours with CHSV(i * 16, 255, 255) for a rainbow.
Frequently asked questions
How do I wire the FastLED WS2812 Ring 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?
FastLED paints a 16-pixel WS2812 ring by quarters.
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