NEO PIXEL LED STRIP 12 TO ATTINY

 

 NeoPixel LED Strip Control Using ATtiny (Pin 12)

This project builds a compact NeoPixel LED controller using an ATtiny microcontroller. A potentiometer adjusts brightness or color, and a push button switches between lighting modes. A capacitor ensures stable power for the LED.

The LED used is WS2812 (commonly called NeoPixel), which allows full RGB color control using a single data pin.


 Components Required

  • ATtiny microcontroller (e.g., ATtiny85)

  • WS2812 / NeoPixel LED

  • 10kΩ Potentiometer

  • Push Button

  • 1µF Capacitor

  • 5V Power Supply

  • Jumper Wires


 Basic Circuit Connections

1️⃣ NeoPixel (WS2812)

NeoPixel PinConnect To
5V5V Supply
GNDGND
DINATtiny Pin 12
1µF CapacitorBetween 5V and GND (near LED)

 Capacitor helps prevent voltage spikes and ensures stable operation.


2️⃣ Potentiometer (10kΩ)

Pot PinConnect To
Left5V
RightGND
MiddleATtiny Analog Pin (A1)

Used to control:

  • Brightness

  • Or color value (Hue)


3️⃣ Push Button

Button SideConnect To
One SideATtiny Digital Pin (Pin 2)
Other SideGND

 Use internal pull-up resistor in code.


 Working Logic

 Potentiometer

  • Reads analog value (0–1023).

  • Maps value to:

    • Brightness (0–255)

    • Or color variation.

 Button

  • When pressed:

    • Switches to next lighting mode.

    • Modes can include:

      • Solid color

      • Rainbow

      • Breathing effect

      • Flash effect

 NeoPixel

  • Displays selected color/effect.

  • Updates dynamically based on input.


 Example Arduino Code (For ATtiny)

#include <Adafruit_NeoPixel.h>

#define LED_PIN 12
#define NUMPIXELS 1
#define BUTTON_PIN 2
#define POT_PIN A1

Adafruit_NeoPixel pixels(NUMPIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);

int mode = 0;
int lastButtonState = HIGH;

void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
pixels.begin();
}

void loop() {

int potValue = analogRead(POT_PIN);
int brightness = map(potValue, 0, 1023, 0, 255);

int buttonState = digitalRead(BUTTON_PIN);

if (buttonState == LOW && lastButtonState == HIGH) {
mode++;
if (mode > 2) mode = 0;
delay(200);
}

lastButtonState = buttonState;

pixels.setBrightness(brightness);

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();
}

 How It Works

  1. ATtiny reads potentiometer value.

  2. Converts value into brightness.

  3. Button press increases mode number.

  4. NeoPixel updates color based on mode.

  5. Process repeats continuously.


 Possible Lighting Modes

  •  Rainbow cycle

  •  Fade in/out

  •  Flashing strobe

  •  Fire simulation

  •  Sound-reactive (with mic module)

  •  Smooth color transition (HSV control)


What You Learn

✅ ATtiny microcontroller programming
✅ Analog input reading
✅ Digital button input with pull-up
✅ Addressable RGB LED control
✅ Mode switching logic
✅ Compact embedded system design


 Why Add a Capacitor?

The 1µF capacitor:

  • Stabilizes voltage

  • Protects NeoPixel from power spikes

  • Prevents flickering or reset issues

(For longer strips, 1000µF is commonly recommended.)


Applications

  • DIY LED lamp

  • Wearable LED projects

  • Mini mood light

  • Custom gaming LED controller

  • Decorative lighting system

  • Embedded electronics learning kit




Comments