I built this project a few years ago with three normal LEDs and a 3D printed pumpkin. I used an Arduino to control their brightness randomly so that that it looked like a flickering flame. Each LED is connected in series with a resistor to a pin with PWM on the Arduino so that I can control the brightness. And in the code, I change the brightness of each LED to a random value every 50 milliseconds. I 3D-printed my pumpkin, but you can place your LEDs in whatever you have at hand. For example a carved pumpkin or an old lantern. In the setup() function, I set up the LED pins as outputs. And in the loop() function, I use the analogWrite() function to set a random brightness value to each LED, with a 50-millisecond delay between each change of value. int ledPin1 = 9; int ledPin2 = 10; int ledPin3 = 11; void setup() { // Set LED pins as outputs pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); pinMode(ledPin3, OUTPUT); } void loop() { analogWrite(ledPin1, random(10, 255)); delay(50); analogWrite(ledPin2, random(10, 255)); delay(50); analogWrite(ledPin3, random(10, 255)); delay(50); } It's actually pretty simple with the ATtiny85. (If you're an Ohmify member, you can learn how in the Shrinking Your Arduino Project course in the Ohmify library.) PS: Are you into electronics and need some guidance to get to the level you want to be? Here are two ways I can help you get better at electronics:
|