How to Connect WS2812 or Neopixel RGB LEDs to Arduino


In this tutorial we will see how to connect WS2812 or Neopixel RGB LEDs to Arduino board, you will also find a programming code for your first tests. WS2812/Neopixel RGB LEDs are individually addressable LED modules that contain red, green, and blue LEDs along with a control circuit in a single package. These LEDs can be controlled using a microcontroller like Arduino to create various lighting effects and animations.

Hardware Required

You will require the following Hardware Components for interfacing the WS2812 or Neopixel RGB with Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Now
WS2812 or Neopixel RGB LEDs1Buy Now
Electrolytic Capacitor 1000uF1Buy Now
Resistor 470Ω1Buy Now
2.1mm Jack Screw Terminal1Buy Now
9v DC Adapter (Optional)1Buy Now
Jumper Wires7Buy Now
Breadboard1Buy Now

What is the WS2812 or Neopixel RGB LEDs?

WS2812/Neopixel RGB LEDs are a type of smart LED module that allows individual control of each LED in the module. They are commonly used in various lighting applications such as decoration, stage lighting, and gaming peripherals.

Neopixel is a brand created by Adafruit Industries to refer to some individually addressable RGB LEDs, that is, LEDs that have an integrated logic circuit within themselves, a circuit that makes it possible to control the color of each LED in a sequence with a single digital pin. of chained LEDs. Not all individually addressable LEDs are Neopixel, only those based on one of these drivers: WS2812 ,  WS2811  or  SK6812. 

Each LED has 4 pins:

  • GND – Low level supply
  • 5V – High level supply
  • DIN – Pin that receives color information
  • DO – Pin that delivers color information


The integrated circuit of each LED can store 3 bytes, one byte for each color. Because they are chained, only the first LED is connected to the Control Pin, in this case, a digital pin of the Arduino Uno card. The card will send the chain of all the colors according to the number of pixels that are connected and in turn the first LED will receive the information all the colors one after the other.But how do all the pixels manage to receive the information? Very simple, when an LED receives 3 new bytes of information, it delivers to the next LED the 3 bytes it previously contained.

In this way, when the Arduino card finishes sending all the colors through the data pin, the first LED would have received and sent all the colors. colors to finally stay with the color that corresponds to it and thus the other LEDs.

In this way, a chain of Neopixel LEDs is a digital output device, that is to say , its operation consists of receiving the color information and displaying it.


  1. WS2812/Neopixel RGB LEDs have a built-in control circuit that allows individual control of each LED in the module.
  2. They require a 5V power supply and can draw up to 60mA per LED at full brightness.
  3. They come in various sizes and shapes, including strips, rings, and matrices.
  4. Each LED module contains three LEDs (red, green, and blue) that can be mixed to create any color.


  1. WS2812/Neopixel RGB LEDs are easy to control using a microcontroller like Arduino.
  2. They can be daisy-chained together to create longer LED strips or larger matrices.
  3. They can create various lighting effects and animations using different programming techniques.
  4. They can be controlled using various programming languages, including Arduino, Python, and C++.
  5. They are available in waterproof and non-waterproof versions for outdoor and indoor use, respectively.



Pin Configuration

Pin NamePin Type
+5VPositive supply Pin
DATAData Pin
GNDGround Pin

Circuit Diagram

The following circuit shows you the connection of the WS2812 or Neopixel RGB with Arduino Please make the connection carefully


Circuit Connections

ArduinoWS2812 RGB LEDs
D6Data through R1

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Installing Libraries

Now when you are Ready to upload the code, to the Arduino Board you will need first to add the Following Libraries in Arduino, If you Learn How to add the library in the Arduino step-by-step guide click on how to install the library Button given Blow


The following we load in arduino and observe how the Neopixels light up one by one.

//For more Projects:

// Based on the "simple" example from the Adafruit NeoPixel library

#include <Adafruit_NeoPixel.h> //Include the library in the code

// Pin of the Arduino to which we connect the DIN of the first led in the chain
#define PIN 6

// Number of chained pixels
#define NUMPIXELS 10 //Modify this number according to the array of LEDs you have

// We initialize our object "pixels"
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of chained pixels
// Argument 2 = Arduino pin number used with data pin
// Argument 3 = Pixel type flags:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

#define DELAYVAL 500 //wait time in ms

void setup() {
  pixels.begin(); // We initialize the object "pixels"

void loop() {
  pixels.clear(); // We turn off all the LEDs

  // The first pixel of a string is #0, the second is #1, and so on
  // up to the number of pixels minus one
  for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
    // We modify the #i LED, lighting it with a moderately bright green color
    pixels.setPixelColor(i, pixels.Color(0, 150, 0));; // We send all the colors with the update done
    delay(DELAYVAL); // Pause before changing the color of the next LED

Code Example 2

We will used FastLED library to control WS2812 LED strip in this code. First download the library given above and add it your Arduino Library list:

#include <FastLED.h>
#define LED_PIN     6
#define NUM_LEDS    8
void setup() {
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
void loop() {
  for (int i = 0; i <= 7; i++) {
    leds[i] = CRGB ( 0, 0, 255);;
  for (int i = 7; i >= 0; i--) {
    leds[i] = CRGB ( 255, 0, 0);;
   for (int i = 0; i <= 7; i++) {
    leds[i] = CRGB ( 0, 255, 0);;


  1. WS2812/Neopixel RGB LEDs are commonly used in decorative lighting applications such as Christmas lights and LED strips for room decoration.
  2. They are used in stage lighting and music performances to create various lighting effects.
  3. They are used in gaming peripherals such as keyboards and mice to create RGB lighting effects.
  4. They are used in commercial lighting applications such as outdoor billboards and signage.


WS2812/Neopixel RGB LEDs are a versatile and easy-to-use LED module that can be used in various lighting applications. With their individually addressable LEDs and easy controllability, they are a popular choice among hobbyists and professionals alike.

Leave a Comment