Smajdalf:
From your schematic I guessed the application is wait for button press -> send IR command -> do nothing until next button press.
That's exactly what my setup does, except that I don't mind the mcu consuming juice while it does nothing. Also a red led is present near button to confirm line continuity.
Also you show batteries so I guessed you are running from batteries. If it is true power consumption of the MCU is probably much much more than rest of the application. When you don't use sleep MCU will consume like 99% of batteries. On the other hand using sleep will reduce average consumption to single uAs - less than self discharge of "normal" batteries.
It is powered by battery 'at the moment'. Originally I planned on the sleep function with the "lowpower" but then I scrapped that idea because the project consumption was already low enough and met my expectation.
If my assumptions are correct you will need to replace batteries every few months when using AAs and no sleep. With sleep you can run from 2 AAs "forever" - limited more by self discharge. Even if you don't plan to do this now you may want to implement sleep in the future when you are more experienced/bored replacing batteries. If so analog method will limit you - you will have to change hardware too which may be inconvenient. But for now if you are not interested in current consumption the analog method is probably easier to implement.
I was planning to run it on a 3v wall wart but then I have a lot of Zinc Carbon cells lying around with absolutely no use, so I thought I could use them instead of throwing them away. Battery life more than 1 month was my expectation. I know sleep could take it more than a year like you sugested but I feel lazy so I chose the easy way.
On the other hand I have a lot of 3V 150mA Solar cells lying around with no use at all, so I could use them when I get bored of replacing cells.
Another thoughts about your curcuit: you have no decoupling cap on ATTiny's power lines. Also you are driving the IR LED directly by a pin. Don't expect current anywhere close to 40mA when powered from 3V. I expect something around 10mA in setup shown. If you need more, use a transistor.
Are decoupling caps really needed? if so which value should I choose?
About the LED thanks for the tip, I will use a 2N2222A with a 470R base resistor to power them.
Noobian:
Are decoupling caps really needed? if so which value should I choose?
Noone knows. It is said 100nF cap is needed as close to MCU power pins as possible. Maybe you may want to add some larger electrolyte cap if internal resistance of batteries is too high.
Actually I have another Idea. How long does it take for an ATtiny13a to boot up and reach the loop function?If it is really low then can this setup work out?
MCU gets power only when button is pressed. Capacitor gives it juice for an extra couple of seconds to execute the IR code and then power runs out and MCU s off. The code is just a few lines --> send an IR signal just once and the code is done.
The circuit as drawn won't work as described. ATTiny "boots" in order of ms unless you have some bootloader on it so if it is possible to do something like that. But it would likely need more complicated circuit.
One of the most stupid statements you have ever posted and that is saying something. Yes everyone knows you always need a 0.1uF decoupling cap on each chip. It is not optional.
You can buy hundreds of them for pennies from your favourite electronics retailer (RS, Farnell, Rapid, etc.)... or go on eBay and spend a little more to get a selection box of various values...
Fair comment. I managed to repurpose a half-broken quad NAND gate (2 gates failed, but 2 worked) a while back. I was unconscionably smug for a while after that...
Grumpy_Mike:
One of the most stupid statements you have ever posted and that is saying something.
I wonder why you consider the statement stupid. Can you explain it please? My reasoning:
It is not known how much noise can the chip tolerate and still work properly.
It is hard (impossible for me) to measure how much noise there is on the power lines.
It is difficult to determine how much more noise the chip will tolerate before malfunctioning. So aim is to reduce the noise "to be sure".
It is also difficult to say which cap is best in reducing the noise. So a "common" value is chosen. Everyone uses 100nF so they are cheap and so everyone uses 100nF and so on. 83nF could be the best value for given circuit and 132nF for another but since 100nF works too noone cares and so noone knows.
In fact OP's circuit works without any decoupling cap. I tried to use ATTiny13A without cap too and it worked. This clearly disproves your statement 0.1uF cap is always needed. But since it is easier to add the cap than analyzing if the circuit is stable enough without cap (nearly) everyone adds it.