science tinker

Spinning NeoPixel ring: Arduino project with wiring and code

Breadboard wiring for Spinning NeoPixel ring, as drawn in the simulator.

A ring of 12 NeoPixels is on pin 6. Light one pixel at a time so the dot runs round the ring: pixel 0, then 1, up to 11, then 0 again. Move every 100 ms and keep all the other pixels off.

  • Arduino Uno
  • Intermediate level
  • 2 parts
  • Free, in your browser

You will learn: Using a loop counter as the pixel number, the % operator to wrap round, and clear() to switch the old pixel off.

Project 34 of 62 in the project gallery.

Parts you need

PartHow manyWhat it does in this project
Arduino Uno1Runs your sketch and powers the circuit.
NeoPixel ring1NeoPixels arranged in a circle (12, 16 or 24): clocks, compasses, loading spinners.
Breadboard and jumper wires1Hold 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:

PartConnection
NeoPixel ring12 LEDs: 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 ring(12, 6, NEO_GRB + NEO_KHZ800);
int dot = 0;

void setup() {
  ring.begin();
  ring.setBrightness(60);
}

void loop() {
  ring.clear();                                   // all pixels off
  ring.setPixelColor(dot, ring.Color(0, 80, 255));
  ring.show();
  // move dot to the next pixel; after 11 comes 0
  delay(100);
}

Build it step by step

  1. Open the project. Press Build it in the Studio. The parts are already in the tray.
  2. Place and wire the parts. Follow the wiring table above, or switch on the guide rings.
  3. Write the code. Complete the starter sketch in the Code panel, in text or with blocks.
  4. Run it. Press ▶ Run and use the part's slider, button or switch to test it. The Serial Monitor shows what your sketch prints.
  5. 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 Spinning NeoPixel ring project do?

A ring of 12 NeoPixels is on pin 6. Light one pixel at a time so the dot runs round the ring: pixel 0, then 1, up to 11, then 0 again. Move every 100 ms and keep all the other pixels off.

What parts do I need for the Spinning NeoPixel ring project?

An Arduino Uno, neoPixel ring, a breadboard and jumper wires.

How do I wire the Spinning NeoPixel ring project?

NeoPixel ring: 12 LEDs: 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 Spinning NeoPixel ring project?

Using a loop counter as the pixel number, the % operator to wrap round, and clear() to switch the old pixel off.

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.

More intermediate projects

Components in this project

Know someone who would use this?

It’s free for every learner. Send it to your class, team or club.

Updated · Free, no sign-up ·