3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Flameless candle from an attiny13

Flameless candle from an attiny13
I need to light my jack-o-lanterns, but this year I wanted something better then a regular candle. I want to flicker, but I want to get rid of the flame.

Any fire is dangerous, especially around kids, burny melty pumpkins stink, and regular candles need to be replaced quite often. So I searched around for a project to copy, oddly enough I could not find one I liked, so I created one myself. My original proof of concept was on an arduino, but that is a bit pricey for a simple candle. Once I proved it would work, I found a way to do it cheap.

Here is how I did it, out of the stuff I had on hand.

My first circuit and my first instructable.
 
Remove these adsRemove these ads by Signing Up
 

Step 1The parts

The parts
I used what I had on hand. This came out to.

1) ATtiny13 x1
2) Red led x1
3) Yellow led x1
4) 100 ohm resistors x2
5) 8pin socket x1
6) thru hole switch x1
7) battery holder for 2AA batteries x1
8) perf board

resistors will vary based on your leds, you can probably find a better switch than I, you can even skip the perf board and wire it up dead bug if you want.
« Previous StepDownload PDFView All StepsNext Step »
34 comments
Dec 1, 2011. 5:58 AMscottinnh says:
Pardon my ignorance.. but would the article's supplied .hex file work (as is) on an ATtiny85?

I'm using avrdude and the Adafruit USBtinyISP, and it seems to flash. No errors on the avrdude's output (everything done, ok, thank you). Command was `sudo avrdude -c usbtiny -p t85 flash:w:AVRCandle.hex`

Yet when I plug in a 3v power source.. nothing, I'm not using a switch, just direct Vcc to pin 8.

And If I pull the ATtiny85 and run VCC directly to the anodes (positive end) of the LEDs, they light up, which confirms the remaining circuit is valid.

I assume whatever has gone wrong for me is to do with my chip or the flash.
This is a nice simple instructable - it's Hello World. It's also like the third ATtiny tutorial I've tried following to no success (the others are more complex, for sure).

Does anything stand out? Is my avrdude command correct? I am also assuming the ATtiny85 isn't radically different from the tiny13. Thoughts?
Dec 1, 2011. 9:27 AMscottinnh says:
Thanks for the speedy and specific suggestions. I trust it works, and I am just having bad luck. :-)

Of those suggestions, the two I should look into are the fuses and the pins (datasheet tiny 85 vs tiny13). I'll look into those two, and try the other code. When it is solved I'll post what the problem was (to help future time travelers who have the same problem)

I know the pin1 is correctly located, and my power supply is set and measured to 3v. I have tried 4 different chips.

FYI there are versions of the ATtiny 25/45/85, but they all handle the 2.7V to 5.5v range. The PU model (which I have) is 1.8v-5.5v.
Sep 10, 2010. 3:55 PMpunkzter says:
Did you have to burn the fuses on the chip? What settings did you use?

Thanks!
Apr 15, 2010. 9:54 PMpurpulhaze says:
Can you explain the code? I'm trying to figure out how to add another led if possible.
Apr 20, 2010. 8:15 AMpurpulhaze says:
from what I can tell seems it would be easier to find another micro controller to add more leds since there are really only 2 general purpose i/o pins and need the other ones ffor programming. 
Oct 7, 2011. 6:54 PMicebat21 says:
How would you modify the code to work on the other pins?
i absolutely love this project BTW.
Mar 7, 2009. 3:16 PMsiklosi says:
Hi,
I saw this project and decided to make it. Arther playing little in bascom I made pwm version of avr candle. Here is link to hex and bas file... http://www.transpapers.com/pwmcandle.zip circuit is not modified but during programming lfuse should be changed from default 6A to 7A (Divide clock by 8 internally; CKDIV8=0 disabled) so there is no flicker from pwm... I'm not code guru but I personally like more this pwm version... it's not hard for eyes and looks more like real fire. Basic code is also included in archive
Feb 18, 2009. 11:15 AMdrgabler says:
Built this last nigh. In a dark room this gives you a pretty bad headache and drives you batty. We need to make some changes to the code to be nicer.
Feb 18, 2009. 4:51 PMdrgabler says:
Yep that is why I said WE not YOU :). Yeah I had it obscured by frosted glass. I thought I was living the effects of a serious bender the headache I got. I tried adding in a delay, it got better but...... Love the Simple project.
Dec 8, 2008. 4:35 PMsotsirh194 says:
what software and programmer did you use?
Nov 27, 2008. 10:21 AMblackrazor says:
I just built this as my first attiny13 project, and it worked perfectly! Thanks for the Instructable- it is terrific!
Oct 20, 2008. 7:18 PMMixMasterM says:
Nice project - I like the effect produced by the dual LEDs. Looking at them directly, it's not that great, but as a test, I placed a paper towel over the LEDs to act as a diffuser, and the effect was pretty cool with the lights off.

I felt that the blinking was a bit fast, so I added a delay based upon code by SolidSilver in his flickering LED candle project (thanks SS!).

BTW, I compiled and ran this on an ATtiny45, so we know it works on the 13 and 45 at least.

// =============================================================================
// My version of the flameless candle code.
// Function delay_ms and the _delay_loop_2 borrowed from an Instructable
// by SolidSilver (who also helped me with his particular project) called
// "Flickering LED candle".
//
// Change the FLICK_DELAY as needed. I felt that a bit of delay gave the
// resulting flicker a bit more realism.
// - 10/20/2008 - cheeze69 on Instructables
// =============================================================================

#include <avr/io.h>
#include <util/delay.h>
static inline void _delay_loop_2(uint16_t count) attribute((always_inline));
#define delay_us(us) _delay_loop_2((unsigned int)(((float)F_CPU*us)/4000000L))
#define FLICK_DELAY 2000

void delay_ms(uint16_t x)
{
while(x--)
{
delay_us(1000);
}
}

int main(void) {
int thePin = 0x0;
long randVal;
srandom(123); //random seed
DDRB = 0x3; // B0-1 set to output

for(;;) {
randVal = random(); // choose a pin
if((randVal % 2) == 0) {
thePin = 0x0;
}
else {
thePin = 0x1;
}

randVal = random(); //high or low
if((randVal % 2) == 0) {
PORTB &= ~(1 << thePin); // x &= ~(1 << n); forces the nth bit of x to be 0. all other bits left alone.
}
else {
PORTB |= (1 << thePin); // x |= (1 << n); forces the nth bit of x to be 1. all other bits left alone.
}
delay_us(FLICK_DELAY);
}

}
Oct 23, 2008. 8:34 AMMixMasterM says:
Yeah, it is probably too big. The "rand" function uses a lot of memory and the tiny13 isn't packed with memory (that's why I bought a bunch of tiny45 instead of tiny13).
Oct 22, 2008. 1:42 PMiBOLIT says:
post hex file please
Oct 20, 2008. 1:20 PMCADDBOY says:
can this be accomplished by using a 555 timer?
Oct 21, 2008. 3:16 PMuterrorista says:
I guess not. You only can set fixed duty cycle. Not random!
Oct 20, 2008. 5:51 PMrockyt says:
what are you using to get the code to the ic?
Oct 21, 2008. 1:05 PMfacegarden says:
There is always the lovely Atmel STK-500, the dev board designed to program these things. They aren't as cheap as other options but they make things so easy it really is nice. Plus, most people don't know this, but students get 50% off on development kits from Atmel. You'd have to call them for details but it could save you $50 or so, i forget how much my STK-500 was. -Taylor
Oct 20, 2008. 12:16 PMKiteman says:
Could you add a short video of it, to let us see how realistic the effect is?
Oct 20, 2008. 5:25 PMTheWelfareWarrior says:
I've heard of people using music as the flicker... not only is it semi random (i guess music has a beat...) but you could tune it to get better results...

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
6
Followers
2
Author:aballen