CCNAP

TPL-04Templates/NeoPixel Colour Cycle

NeoPixel Colour Cycle

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

Open in Playgroundbeginner · NeoPixel · WS2812B · RGB · animation
beginner

FIG. 1NeoPixel Colour Cycle · circuitTPL-04

02Sketch

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);
  }
}

03Components

  • 01Arduino Uno
  • 02NeoPixel (wokwi-neopixel)

04Wiring

Component pinArduino pin
VDD (VCC)5V
VSS (GND)GND
DIN (Data In)Pin 6

All templates

Ready when you are

Have a circuit in mind?

No hardware, no installs — a browser is enough.