Projects / Ring-shaped focus timer

Ring-shaped focus timer

A 16-LED ring fills up over a 25 minute work block and then flashes for a break.

Beginner2.5 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. NANO19.1 mA

    Wire the ring

    5V, GND and DIN through 330 ohm to D6.

  2. NANO19.2 mA

    Add the capacitor

    100 microfarad across the ring power, stripe to GND.

  3. NANO

    Wire the button

    D2 to GND.

  4. NANO

    Set TIME_SCALE to 60

    Test with quicker minutes first.

  5. NANO

    Upload the sketch

    One blue LED waits.

  6. NANO19.2 mA

    Press the button

    The work block starts and the red ring fills.

  7. NANO

    Press again

    Pause shows a dim yellow LED, press to resume.

  8. NANO19.2 mA

    Wait for the block to end

    The ring flashes green then the break starts.

In short

How do you build a ring-shaped focus timer?

A 16-LED ring fills up over a 25 minute work block and then flashes for a break. 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 8 steps and about 150 minutes.

Level
Beginner
Time
About 150 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Ring 5VNano 5VPower, with a 100 microfarad capacitor between 5V and GND
Ring GNDNano GNDGround
Ring DINNano D6 through 330 ohmData, the resistor protects the first LED
ButtonNano D2 to GNDStart, pause and reset

Code

The Pomodoro method is a way to focus: work for 25 minutes, rest for 5, and take a longer rest after four blocks. The ring shows how much of the block has passed by lighting one more LED at each sixteenth of the time, which is about 94 seconds for a work block. The sketch keeps a small state machine with idle, work, break and paused states. A press of the button starts the timer or pauses and resumes it, and the elapsed time is saved so a pause does not lose progress. When a block ends the ring flashes, green for the end of work and orange for the end of a break, and the next block starts. The timing uses millis, so it stays correct while the loop runs. TIME_SCALE speeds the whole timer up so you can test it in a minute rather than half an hour. The ring is bright, so the brightness is set low, which keeps the current under about 100 milliamps and the colours easy on the eyes. The 330 ohm resistor on the data line and the capacitor across the supply protect the first LED from voltage spikes.

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;
const int BUTTON = 2;
const int N = 16;
Adafruit_NeoPixel ring(N, RING_PIN, NEO_GRB + NEO_KHZ800);

// Set TIME_SCALE to 60 to test quickly, 1 for real minutes
const unsigned long TIME_SCALE = 1;
const unsigned long WORK_MS = 25UL * 60UL * 1000UL / TIME_SCALE;
const unsigned long BREAK_MS = 5UL * 60UL * 1000UL / TIME_SCALE;
const unsigned long LONG_BREAK_MS = 15UL * 60UL * 1000UL / TIME_SCALE;

enum State { IDLE, WORK, BREAK, PAUSED };
State state = IDLE, resumeState = WORK;
unsigned long startedAt = 0, elapsedBefore = 0, blockLength = WORK_MS;
int blocksDone = 0;

void fill(int count, uint32_t colour) {
  ring.clear();
  for (int i = 0; i < count && i < N; i++) ring.setPixelColor(i, colour);
  ring.show();
}

void flash(uint32_t colour) {
  for (int k = 0; k < 6; k++) {
    fill(N, colour); delay(250);
    fill(0, 0);      delay(250);
  }
}

void begin(State s, unsigned long len) {
  state = s; blockLength = len; startedAt = millis(); elapsedBefore = 0;
}

bool pressed() {
  if (digitalRead(BUTTON) == LOW) {
    delay(40);
    while (digitalRead(BUTTON) == LOW) {}
    return true;
  }
  return false;
}

void setup() {
  pinMode(BUTTON, INPUT_PULLUP);
  ring.begin();
  ring.setBrightness(20);                    // low brightness keeps the current small
  fill(1, ring.Color(0, 0, 255));
}

void loop() {
  if (pressed()) {
    if (state == IDLE)        begin(WORK, WORK_MS);
    else if (state == PAUSED) { state = resumeState; startedAt = millis(); }
    else { elapsedBefore += millis() - startedAt; resumeState = state; state = PAUSED; }
  }

  if (state == WORK || state == BREAK) {
    unsigned long elapsed = elapsedBefore + (millis() - startedAt);
    if (elapsed >= blockLength) {
      if (state == WORK) {
        blocksDone++;
        flash(ring.Color(0, 255, 0));
        begin(BREAK, (blocksDone % 4 == 0) ? LONG_BREAK_MS : BREAK_MS);
      } else {
        flash(ring.Color(255, 120, 0));
        begin(WORK, WORK_MS);
      }
    } else {
      int lit = (int)((elapsed * N) / blockLength) + 1;
      fill(lit, state == WORK ? ring.Color(255, 40, 0) : ring.Color(0, 120, 255));
    }
  } else if (state == PAUSED) {
    fill(1, ring.Color(60, 60, 0));
  }
  delay(100);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Press to startRed ring starts filling
Press during workPause, progress kept
Press to resumeRing continues
End of work blockGreen flash, then blue break
Fourth blockLonger break

If it does not work

Ring stays dark

Check the DIN wire goes to the IN side, not OUT.

Wrong colours

Change NEO_GRB to NEO_RGB for your ring.

First LED flickers

Add the resistor and the capacitor.

Timer too slow to test

Set TIME_SCALE to 60.

Ring restarts by itself

Power is weak, lower the brightness or use a better supply.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the ring-shaped focus timer?

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 ring-shaped focus timer take to build?

About 150 minutes for a beginner maker, in 8 steps.

How do I know the ring-shaped focus timer works?

Press to start: Red ring starts filling. Press during work: Pause, progress kept. Press to resume: Ring continues.

Ring stays dark: what should I check?

Check the DIN wire goes to the IN side, not OUT.

Wrong colours: what should I check?

Change NEO_GRB to NEO_RGB for your ring.

First LED flickers: what should I check?

Add the resistor and the capacitor.

Timer too slow to test: what should I check?

Set TIME_SCALE to 60.