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

QtyPartWhat it does
1Arduino Unothe microcontroller board
1NeoPixel ringA ring of WS2812 pixels. DIN from a pin, VCC to 5V, GND to GND.

Wiring

#FromTo
1Arduino Uno pin 6NeoPixel ring DIN
2Arduino Uno 5VNeoPixel ring VCC
3Arduino Uno GNDNeoPixel ring GND

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a NeoPixel ring from the parts palette.
  3. Wire 1. Connect Arduino Uno pin 6 to NeoPixel ring DIN.
  4. Wire 2. Connect Arduino Uno 5V to NeoPixel ring VCC.
  5. Wire 3. Connect Arduino Uno GND to NeoPixel ring GND.
  6. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  7. 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