LED ring wheel of fortune
A Nano spins a bright dot round a 16-LED ring when you press a button, slows it down and stops it on a random LED, as a prize wheel or a way to choose who goes first.
Build it step by step
0 of 7 doneWire the ring
5V and GND to the Nano, DIN through 330 ohms to D6.
Add the capacitor
Across the ring's 5V and GND, stripe to GND.
Wire the button
D2 to GND.
Install the library
Adafruit NeoPixel.
Upload the sketch
The ring is dark.
Press the button
A dot spins round and slows to a stop.
Spin again
A different LED wins.
How do you build an LED ring wheel of fortune?
A Nano spins a bright dot round a 16-LED ring when you press a button, slows it down and stops it on a random LED, as a prize wheel or a way to choose who goes first. You need Arduino Nano, WS2812B ring 16 LEDs, Tactile push button 6 mm, Resistor 330 Ω, Electrolytic Capacitor 100 µF and Breadboard 830 Tie Points. It takes 7 steps and about 110 minutes.
- Level
- Beginner
- Time
- About 110 min
- Parts
- 6
Parts list
- Development BoardsBuyArduino Nano × 1
- OptoelectronicsBuy
- SwitchesBuy
- PassivesBuyResistor 330 Ω × 1
- PassivesBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Ring 5V | Nano 5V | Power from USB (brightness is kept low) |
| Ring GND | Nano GND | Common ground |
| Ring DIN | 330 ohm resistor to Nano D6 | Data line |
| 100 microfarad capacitor | Across ring 5V and GND, stripe to GND | Steadies the supply |
| Button | Nano D2 and GND | Starts a spin |
Code
A WS2812B ring has a tiny control chip in every LED, so one data wire sets the colour of all sixteen. The Adafruit NeoPixel library sends the colours, and the 330 ohm resistor in the data line protects the first LED while the capacitor smooths the supply when many LEDs change at once. Each LED can draw about 60 milliamps at full white, so the program keeps the brightness low and lights only a dot and a short tail at a time, which keeps the total current well within what a USB port can give. When the button is pressed the program picks a random number of steps and moves the dot round the ring, adding a longer wait at each step so it slows down smoothly. It flashes the winning LED green. The random numbers are seeded from an unconnected analog pin and the clock, so each spin differs. Do not look into the LEDs from close up at high brightness. Number the LEDs on a card around the ring for prizes, names or choices.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Adafruit_NeoPixel.h>
const int RING_PIN = 6, BUTTON = 2, COUNT = 16;
Adafruit_NeoPixel ring(COUNT, RING_PIN, NEO_GRB + NEO_KHZ800);
void dot(int p) {
ring.clear();
ring.setPixelColor(p % COUNT, ring.Color(255, 140, 0));
ring.setPixelColor((p + COUNT - 1) % COUNT, ring.Color(50, 28, 0)); // a short tail
ring.setPixelColor((p + COUNT - 2) % COUNT, ring.Color(12, 7, 0));
ring.show();
}
void setup() {
pinMode(BUTTON, INPUT_PULLUP);
ring.begin();
ring.setBrightness(40); // low, so a USB port can power the ring
ring.clear();
ring.show();
randomSeed(analogRead(A0) + micros());
}
void loop() {
static int pos = 0;
if (digitalRead(BUTTON) == LOW) {
int total = random(40, 80); // how many steps this spin lasts
for (int i = 0; i < total; i++) {
pos = (pos + 1) % COUNT;
dot(pos);
delay(15 + ((unsigned long)i * i * 300UL) / ((unsigned long)total * total)); // slows to a stop
}
for (int k = 0; k < 6; k++) { // flash the winner
ring.clear();
ring.setPixelColor(pos, ring.Color(0, 255, 0));
ring.show();
delay(200);
ring.clear();
ring.show();
delay(200);
}
dot(pos);
}
delay(10);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Press the button | A dot spins fast |
| Watch the end | It slows down and stops |
| Winner | Flashes green six times |
| Press again | A new random result |
| Ten spins | Different winners |
If it does not work
Ring stays dark
Check the arrow on DIN, 5V and GND.
Wrong colours
Change NEO_GRB to NEO_RGB.
Nano resets
Lower the brightness number and use a better USB port.
First LED flickers
Check the resistor is on the data wire.
Always stops at the same LED
Check the analog pin A0 is not wired to anything.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the LED ring wheel of fortune?
Arduino Nano, WS2812B ring 16 LEDs, Tactile push button 6 mm, Resistor 330 Ω, Electrolytic Capacitor 100 µF and Breadboard 830 Tie Points.
How long does the LED ring wheel of fortune take to build?
About 110 minutes for a beginner maker, in 7 steps.
How do I know the LED ring wheel of fortune works?
Press the button: A dot spins fast. Watch the end: It slows down and stops. Winner: Flashes green six times.
Ring stays dark: what should I check?
Check the arrow on DIN, 5V and GND.
Wrong colours: what should I check?
Change NEO_GRB to NEO_RGB.
Nano resets: what should I check?
Lower the brightness number and use a better USB port.
First LED flickers: what should I check?
Check the resistor is on the data wire.
