NeoPixel LED Strip Control Using ATtiny85 (Pin 12)
Build a compact WS2812 NeoPixel controller with an ATtiny85 microcontroller. A potentiometer adjusts brightness and a push button cycles through lighting modes — all on a tiny chip with one data pin.
1Project Overview
How the system works at a glance
System overview: Potentiometer + Button → ATtiny85 → WS2812 NeoPixel
2Components Required
All parts needed for this build
3Circuit Connections
Pin-by-pin wiring reference for all three components
WS2812 NeoPixel LED
| NeoPixel Pin | Connect To | Notes |
|---|---|---|
| 5V | 5V power supply | Direct from supply, not from ATtiny |
| GND | Common GND | — |
| DIN | ATtiny Pin 12 (PB0) | Single data wire |
| 1µF Cap | Between 5V and GND | Place close to LED, prevents voltage spikes |
POT Potentiometer (10kΩ)
| Pot Pin | Connect To | Purpose |
|---|---|---|
| Left terminal | 5V | Voltage reference high |
| Right terminal | GND | Voltage reference low |
| Wiper (middle) | ATtiny A1 (PB2, pin 7) | Reads 0–1023, maps to brightness 0–255 |
BTN Push Button
| Button Pin | Connect To | Notes |
|---|---|---|
| One side | ATtiny Pin 2 (PB3, pin 2) | Use INPUT_PULLUP in code — no resistor needed |
| Other side | GND | Active LOW when pressed |
4Circuit Diagram
Complete schematic wiring
Full circuit schematic — ATtiny85 + WS2812 + potentiometer + push button
5Step-by-Step Build Guide
Build in this exact order
6ATtiny85 Code
Full sketch using Adafruit NeoPixel library
// ──────────────────────────────────────────────────────────── // NeoPixel WS2812 Controller — ATtiny85 // makemindz.com // Pot → brightness | Button → mode switch (R/G/B) // ──────────────────────────────────────────────────────────── #include <Adafruit_NeoPixel.h> // ── Pin Definitions ────────────────────────────────────────── #define LED_PIN 0 // PB0 = physical pin 5 (labelled Pin 12 in library) #define NUMPIXELS 1 // Number of NeoPixels — increase for strips #define BUTTON_PIN 3 // PB3 = physical pin 2 #define POT_PIN A1 // PB2 = physical pin 7 (ADC1) // ── NeoPixel Setup ─────────────────────────────────────────── Adafruit_NeoPixel pixels(NUMPIXELS, LED_PIN, NEO_GRB + NEO_KHZ800); // ── State Variables ────────────────────────────────────────── int mode = 0; // Current lighting mode (0=Red, 1=Green, 2=Blue) int lastButtonState = HIGH; // Previous button state for edge detection // ── Setup ───────────────────────────────────────────────────── void setup() { pinMode(BUTTON_PIN, INPUT_PULLUP); // No external resistor needed pixels.begin(); pixels.clear(); pixels.show(); } // ── Main Loop ───────────────────────────────────────────────── void loop() { // Read potentiometer (0–1023) → map to brightness (0–255) int potValue = analogRead(POT_PIN); int brightness = map(potValue, 0, 1023, 0, 255); // Detect button press (falling edge: HIGH → LOW) int buttonState = digitalRead(BUTTON_PIN); if (buttonState == LOW && lastButtonState == HIGH) { mode++; if (mode > 2) mode = 0; // Wrap back to mode 0 delay(200); // Simple debounce } lastButtonState = buttonState; // Apply brightness from potentiometer pixels.setBrightness(brightness); // Set color based on current mode if (mode == 0) pixels.setPixelColor(0, pixels.Color(255, 0, 0)); // Red else if (mode == 1) pixels.setPixelColor(0, pixels.Color(0, 255, 0)); // Green else if (mode == 2) pixels.setPixelColor(0, pixels.Color(0, 0, 255)); // Blue pixels.show(); // Push data to LED }
NUMPIXELS to the count of your strip. Loop through pixels.setPixelColor(i, ...) for each index. For strips longer than ~8 LEDs, add a 1000µF capacitor instead of 1µF.7Lighting Modes
Possible effects to expand upon
if (mode > 2) limit and add more else if branches. Use pixels.ColorHSV(hue, 255, brightness) for smooth rainbow transitions.8Run the Simulation
Test in your browser before soldering anything
Open the Tinkercad Simulation
The official MakeMindz simulation for this project is live on Tinkercad — includes the ATtiny85, WS2812 ring, potentiometer, button, and full code pre-loaded.
Open Tinkercad SimulationFree Tinkercad account required · Works on desktop browsers
10What You Learn
Skills gained from building this project
11Applications
Real-world uses for this compact controller

Comments
Post a Comment