NEO PIXEL LED STRIP 12 TO ATTINY

NeoPixel LED Strip Control Using ATtiny85 – Complete Guide | MakeMindz
Advanced Project

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.

20–30 min build
ATtiny85
WS2812 · Single data pin
Tinkercad simulation

1Project Overview

How the system works at a glance

Potentiometer 10kΩ · Analog A1 0–1023 → brightness Push Button · Pin 2 ATtiny85 Reads pot + button Controls NeoPixel via Pin 12 (PB0) DIN signal WS2812 NeoPixel 1µF cap across 5V/GND 5V Power Supply

System overview: Potentiometer + Button → ATtiny85 → WS2812 NeoPixel


2Components Required

All parts needed for this build

🔬
ATtiny85
× 1 microcontroller
💡
WS2812 NeoPixel
× 1 (or strip)
🎚️
10kΩ Potentiometer
× 1
🔘
Push Button
× 1 (tactile)
1µF Capacitor
× 1 (electrolytic)
🔌
5V Power Supply
× 1
🪢
Jumper Wires
Assorted
🧩
Breadboard
Half-size
💡
ATtiny85 ProgrammingYou'll need an Arduino Uno as an ISP programmer (or a dedicated USBasp programmer) to upload code to the ATtiny85. Set the Arduino IDE board to "ATtiny85" at 8 MHz internal clock.

3Circuit Connections

Pin-by-pin wiring reference for all three components

WS2812 NeoPixel LED

NeoPixel PinConnect ToNotes
5V5V power supplyDirect from supply, not from ATtiny
GNDCommon GND
DINATtiny Pin 12 (PB0)Single data wire
1µF CapBetween 5V and GNDPlace close to LED, prevents voltage spikes

POT Potentiometer (10kΩ)

Pot PinConnect ToPurpose
Left terminal5VVoltage reference high
Right terminalGNDVoltage reference low
Wiper (middle)ATtiny A1 (PB2, pin 7)Reads 0–1023, maps to brightness 0–255

BTN Push Button

Button PinConnect ToNotes
One sideATtiny Pin 2 (PB3, pin 2)Use INPUT_PULLUP in code — no resistor needed
Other sideGNDActive LOW when pressed
⚠️
ATtiny85 Pin MappingATtiny85 physical pin numbering differs from Arduino pin numbers. "Pin 12" in the NeoPixel library refers to PB0 = physical pin 5 of the ATtiny85 DIP-8 package.



4Circuit Diagram

Complete schematic wiring

+5V GND ATtiny85 DIP-8 Package PB5 (RST) PB3 (A3/p2) PB4 (A2) GND VCC PB2 (A1) PB1 PB0 (p12) Potentiometer 10kΩ Left → 5V Right → GND Wiper → A1 A1 Push Button INPUT_PULLUP → ATtiny Pin 2 Pin 2 WS2812 NeoPixel LED R G B 5V GND DIN DIN / Pin12 1µF Cap Data signal (DIN) Analog (pot wiper) Button signal

Full circuit schematic — ATtiny85 + WS2812 + potentiometer + push button

🎨
Why only one data wire? WS2812 LEDs use a proprietary single-wire protocol at 800kHz. Each LED has a built-in driver IC that passes data down the chain — you only need DIN → DOUT chaining for strips. The ATtiny85's Adafruit NeoPixel library handles the timing precisely.

5Step-by-Step Build Guide

Build in this exact order

1
Install ATtiny85 board support in Arduino IDE
Go to File → Preferences → Additional Boards Manager URLs and add the ATtiny board package URL. Then install "ATtiny Microcontrollers" in the Boards Manager. Set board to ATtiny85, clock to 8 MHz (Internal).
2
Burn the bootloader (set fuses)
Using an Arduino Uno as ISP: connect the ATtiny85, upload the ArduinoISP sketch to the Uno, then from the IDE select Tools → Burn Bootloader. This sets the 8 MHz internal oscillator fuse.
Arduino Uno ISP wiring: Uno 10 → ATtiny RESET (pin 1) Uno 11 → ATtiny MOSI (pin 5) Uno 12 → ATtiny MISO (pin 6) Uno 13 → ATtiny SCK (pin 7) Uno 5V → ATtiny VCC (pin 8) Uno GND → ATtiny GND (pin 4)
3
Install Adafruit NeoPixel library
In Arduino IDE go to Sketch → Include Library → Manage Libraries. Search "Adafruit NeoPixel" and install the latest version. This library works with ATtiny85 at 8 MHz.
4
Wire the breadboard
Place the ATtiny85 in the breadboard. Connect the 5V rail and GND rail from your power supply. Wire the potentiometer, push button, and NeoPixel as shown in Section 3. Place the 1µF capacitor across the NeoPixel's 5V and GND pins, as close to the LED as possible.
5
Upload the code via ISP
Reconnect the Arduino Uno ISP wiring from Step 2. Select Tools → Programmer → Arduino as ISP, then Sketch → Upload Using Programmer. Do not use the regular Upload button.
6
Power and test
Disconnect the ISP. Connect your 5V supply. The NeoPixel should light up in red (mode 0). Rotate the potentiometer — brightness should change. Press the button to cycle through green (mode 1) and blue (mode 2).
TroubleshootingIf the LED doesn't respond to the pot, confirm wiper goes to PB2 (physical pin 7). If button doesn't work, confirm INPUT_PULLUP is set and button connects to GND.

6ATtiny85 Code

Full sketch using Adafruit NeoPixel library

Arduino / ATtiny85
// ────────────────────────────────────────────────────────────
// 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
}
💡
Extend to more LEDsChange 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

🔴
Solid Color
R, G, B or any mix
🌈
Rainbow Cycle
HSV hue sweep
🫁
Breathing
Fade in / fade out
Strobe Flash
Rapid ON/OFF
🔥
Fire Simulation
Random warm flicker
🎙️
Sound Reactive
Add mic module
🔧
Adding more modesIncrease the 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 Simulation

Free Tinkercad account required · Works on desktop browsers


10What You Learn

Skills gained from building this project

ATtiny85 programming
Analog input reading
Button input with pull-up
Addressable RGB LED control
Mode switching logic
Compact embedded design
ISP programming workflow
Capacitor decoupling

11Applications

Real-world uses for this compact controller

💡
DIY LED Lamp
👕
Wearable LEDs
🌙
Mood Light
🎮
Gaming LED Strip
🎄
Decorative Lighting
🧪
Embedded Learning

Comments

try for free