CNAP
03 / Templates · beginner

NEOPIXEL COLOUR CYCLE

Open in Playground

A single WS2812B NeoPixel cycling through red, green, blue, and yellow every 600 ms via Adafruit NeoPixel library.

beginnerNeoPixelWS2812BRGBanimation
Circuit
Code
sketch.inoArduino C++
26 lines
// Single NeoPixel — colour cycle
#include <Adafruit_NeoPixel.h>

#define PIN        6
#define NUMPIXELS  1

Adafruit_NeoPixel pixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixel.begin();
  pixel.setBrightness(100);
}

void loop() {
  uint32_t colors[] = {
    pixel.Color(255, 0,   0),   // red
    pixel.Color(0,   255, 0),   // green
    pixel.Color(0,   0,   255), // blue
    pixel.Color(255, 255, 0),   // yellow
  };
  for (auto c : colors) {
    pixel.setPixelColor(0, c);
    pixel.show();
    delay(600);
  }
}
Components
  • Arduino Uno
    01
  • NeoPixel (wokwi-neopixel)
    02
Wiring
Component PinArduino Pin
VDD (VCC)5V
VSS (GND)GND
DIN (Data In)Pin 6