Submit

07 / 20

Fill a ring of LEDs

Map a 12-bit potentiometer reading to twelve addressable pixels.

Run this experiment →
ESP32 teaching illustration with module, GPIO headers and lesson components

Why it’s here

Move the dial from 0 to 4095 and count the illuminated pixels.

How it works

Map a 12-bit potentiometer reading to twelve addressable pixels. Twelve. A single data pin sends color values to every addressable LED in the ring. This guided model targets the original ESP32 and Arduino-ESP32 3.x; radio, acoustics, loads and mechanics are simplified.

Try it

  1. Open this experiment
  2. Move the dial from 0 to 4095 and count the illuminated pixels.

Connections

  • GPIO 34 — Potentiometer wiper; ends 3V3/GND
  • GPIO 23 — Level shifter → ring DIN
  • External 5V / GND — Pixel supply / common ground

Example sketch

#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel ring(12, 23, NEO_GRB + NEO_KHZ800);
// 5V pixel power; common GND; use an appropriate 3.3V-to-5V data level shifter.

void setup() {
  ring.begin();
  ring.setBrightness(40);
  analogReadResolution(12);
}

void loop() {
  int reading = analogRead(34);
  int count = map(reading, 0, 4095, 0, 12);
  for (int i = 0; i < 12; i++) ring.setPixelColor(i, i < count ? ring.Color(20, 120, 80) : 0);
  ring.show();
  delay(20);
}

Check your understanding

How many pixels light at the maximum?

Show the answer

Twelve. A single data pin sends color values to every addressable LED in the ring.

Sources

Arduino-ESP32 ↗ · GPIO reference ↗

MAKE A THOUGHTFUL CHOICE

Your shortlist, side by side.

Pricing models are indicative. Check each official website for current plans and limits.