Amal Mathew
Published © GPL3+

Fading LED with ATtiny85

A candle-like circuit sculpture which uses ATtiny85, LED, 3V coin cell and some copper wires!

BeginnerFull instructions provided15 minutes7,181

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1
LED (generic)
LED (generic)
×1
Coin Cell Battery CR2032
Coin Cell Battery CR2032
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram

Code

Arduino Sketch

Arduino
/*
 Fading LED with ATtiny85 

  

  The analogWrite() function uses PWM, so if you want to change the pin you're
  using, be sure to use another PWM capable pin. 

  This example code is in the public domain.

 
*/

int led = 0;           // the PWM pin the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup() {
  
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  
  analogWrite(led, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}

Credits

Amal Mathew

Amal Mathew

24 projects • 78 followers
Maker | Open source ❤️| Engineer 👉🏽Technology for the Sake of Humanity

Comments