NeoPixel colour cycle: Arduino project with wiring and code
One NeoPixel is wired to pin 6. Show red for half a second, then green, then blue, and repeat forever.
You will learn: How an addressable LED takes its colour as three numbers from 0 to 255 (red, green, blue), and why nothing changes until show() is called.
Project 33 of 62 in the project gallery.
Parts you need
| Part | How many | What it does in this project |
|---|---|---|
| Arduino Uno | 1 | Runs your sketch and powers the circuit. |
| NeoPixel (WS2812B) | 1 | An RGB LED with its own tiny chip: one data wire sets its colour to any of 16 million. |
| Breadboard and jumper wires | 1 | Hold the parts and join them without soldering. |
How to wire it
Put the parts on the breadboard, join the board's 5V and GND pins to the breadboard's power rails, then make these connections:
| Part | Connection |
|---|---|
| NeoPixel | 1 LED: DIN → pin 6 |
In the Studio, the 💡 guide rings show where each wire goes, and the ✔ Check button tells you which connection is missing.
Starter code
Start from this sketch and write the missing lines. The comments say what each part has to do.
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel pixel(1, 6, NEO_GRB + NEO_KHZ800); // 1 pixel on pin 6
void setup() {
pixel.begin();
}
void loop() {
pixel.setPixelColor(0, pixel.Color(255, 0, 0)); // red, green, blue
pixel.show(); // send the colour to the pixel
delay(500);
// now show green for 500 ms, then blue for 500 ms
}
Build it step by step
- Open the project. Press Build it in the Studio. The parts are already in the tray.
- Place and wire the parts. Follow the wiring table above, or switch on the guide rings.
- Write the code. Complete the starter sketch in the Code panel, in text or with blocks.
- Run it. Press ▶ Run and use the part's slider, button or switch to test it. The Serial Monitor shows what your sketch prints.
- Check it. Press ✔ Check: the simulator tests the circuit and the code and tells you exactly what to fix.
Questions students ask
What does the NeoPixel colour cycle project do?
One NeoPixel is wired to pin 6. Show red for half a second, then green, then blue, and repeat forever.
What parts do I need for the NeoPixel colour cycle project?
An Arduino Uno, neoPixel, a breadboard and jumper wires.
How do I wire the NeoPixel colour cycle project?
NeoPixel: 1 LED: DIN → pin 6. Power comes from the board's 5V (or 3.3V) and GND pins along the breadboard rails.
What will I learn from the NeoPixel colour cycle project?
How an addressable LED takes its colour as three numbers from 0 to 255 (red, green, blue), and why nothing changes until show() is called.
Can I build this without real hardware?
Yes. The project runs in the free Science Tinker microcontroller simulator in your browser: place the parts, wire them, write the sketch and press Run. The ✔ Check button tests your circuit and code and tells you what to fix. Nothing to install and no account needed.
Where is the finished code?
The page gives the starter sketch so that you write the important lines yourself. If you are stuck, the 💡 Solution button in the Studio shows a complete, working sketch that you can run and study.