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 ads by
Signing UpStep 1The parts
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 Step | Download PDFView All Steps | Next Step » |








































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?
I don't think there are any differences between the 85 and the 13, other than memory... but I could be wrong. You really have to look at my code and compare to the 85 datasheet, my code may be flipping the wrong pins for your 85. One thing to try is to compile the code posted by MixMasterM below... he was running it on an 85.
Other things to consider.
1) you might have a bad chip, can you try on another 85(better yet a 13)? the problem may be the chip.
2) does your chip need 5v? check the exact version... if you have a 5v version, and are only providing 3v, that might explain why none of your attiny projects work.... and if you go up to 5v... increase your resistors.
3) check the led datasheet, maybe it is working and the voltage from the pin is too low... if you tested the led to vcc through the 100 ohm resistors, this should not be a problem though
3) have the fuses been altered? this project needs the internal oscillator set. I did not alter the fuses from factory settings for this project.
4) check the batteries(use a multimeter), they may be low... 3v to an led usually burns it out, so if vcc is not, maybe your batteries are suspect.
6) if you programmed the chip, it is probably oriented correctly in your circuit... but double check. Pin1 has a dot next to it. The datasheet will show you where each pin in my circuit diagram is physically on the chip.
Don't get discouraged. Sometimes you just need to take a break, and come back with a fresh set of eyes. I know the project seems pretty basic, but coding c for the chip was quite challenging for me at the time.
I can say though that this does work, several people have tested it successfully. Please let us know if you have some success.
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.
Thanks!
Check out AVRFreaks for other tutorials on avrs and avr programming.
PORTB is the variable representing the pins on the attiny.
PORTB &= ~(1 << thePin);
and
PORTB |= (1 << thePin);
is me flipping the bit(a single pin) on and off
to add another led you can
1) simply connect the second led to the same pin
2) add a transistor to the pin, and connect both led to the transistor
3) add the new led to a new pin so it will work independently, you will need to update the code too
i absolutely love this project BTW.
I chose these two pins because my ICSP programmer uses the other 6, though I believe you can use 6 of the pins for IO... two of them will always be needed for VDD and GND
This means you can get 6 leds working here with one pin to a led... you can get even more working with a multiplex, or charlieplex setup.. but again I have not looked at the datasheet in some time.
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
http://www.adafruit.com/index.php?main_page=product_info&products_id=46&sessid=88e60ab616318e736357f41fcc38f51a
the software I used to code was eclipse, with the avr-eclipse plugin. Then avrdude to program the chip. acr-eclipse has some nice hooks into avrdude which make it nice to use, just click and flash the chip.
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);
}
}
The programer
http://www.adafruit.com/index.php?main_page=product_info&cPath=16&products_id=46
The board is something liek this
http://www.evilmadscientist.com/article.php/avrtargetboards