Well I had another microcontroller sitting around so I decided to build a sleep timer. I usually have some sort of sitcom on when I am going to sleep, especially on the weekends, but I don't like the (future) ramification of an increased power bill with the TV on for 10 hours a day. Especially if I'm not actively watching it.
When I am paying my own power bill in my future apartment (in less than a month I suppose) I want even the timer circuit itself to be energy efficient, so I designed it so that when it is off, absolutely nothing is drawing any power. No transformer or rectifier or LED drawing a teeny bit of current, not the slightest watt wasted. Plus the perks of 11.5 hours less of TV operation per day. This makes me very environmentally conscious! I can now sell carbon credits, but I'm not sure how much power the TV actually draws is because my ammeter is cheap and only works up to 200mA AC. But hopefully less than 1.2 kilowatts because the relay I used can only safely break 10A. (Don't worry, I put in some fuses and such... for safety!) Any way, here is a quick video of how this works:
Timer Circuit, part 1
I attached all of this behind the lightning protection on an old surge protector my dad gave me probably more than 10 years ago. I cut the hot (black) conductor inside the surge protector and attached one wire to each of the new ends (one going to my timer, one coming from the timer) and then just attached a third wire for a system neutral/ground.
To preface: I have never cut Plexiglas with anything other than a computer-controlled laser. As is apparent from the pictures, I did not have one of these. But I think the finished product still looks pretty neat! Beats a black Radio Shack project box any way.
I don't think I mentioned in the video, but the light switch on the side is a bypass. If the switch is on, the timer can be on but will not be able to shut the TV off, and vice versa. The universal OFF switch for the entire device (if the timer is running it cannot be stopped besides removing power to the microcontroller) is the original on/off switch on the surge protector that this is attached to.
The only real problem I had is that I mounted the microcontroller too close to the top of the box, and caused a short circuit in it's 12V power cable. It didn't do anything damaging, only caused the relay to not activate. I remounted the microcontroller lower in the box, replaced the power adapter, and now it is just dandy.
So for some reason the bypass switch shorted out. Probably because I found it in a house I used to rent, and my landlords were notorious for buying really, really cheap things around the house. Like CFL bulbs that would burn out every month, or a chain on the back door that was made out of brass and broke after two days. ANY WAY. I coincidentally got my first supply of ATtiny microcontrollers and decided that this was a good chance to liberate the Arduino from this project and play with an ATtiny. And I went ahead and added some functionality while I was playing around.
There are a few details about this project that I didn't share, such as how I was able to allow this device to consume zero power when it is off, and as a note to myself in the future, I wrote it down in my green book. So there.
So the functionality I wanted to add was an adjustable timer. Before, I took an EXTREME programming shortcut with the Arduino as far as the timer functionality went. Pushing the main button automatically started the timer by turning on the Arduino, setting the system time to 0900 hours, and then waiting for 0935 to shut off. Regardless of what time it actually was, every time power was turned on, that's what the Arduino did. It was also impossible to stop the timer once it was started, unless you unplugged the entire device or flipped the switch on the surge protector, which is hidden behind my desk normally, and very hard to access.
I removed the bypass switch (which was faulty) and wired the ATtiny up to the breadboard, adding in a 5V DC regulator for microcontroller power. I also added some control circuitry for a potentiometer (timer length adjustment), an extra LED (existing LED will be used for power indication, and the new one for timer indication), and two new pushbuttons. The existing pushbutton is wired to 120 AC and momentarily delivers power to the circuit when it's pushed, which turns the microcontroller on. But this means that it can't be used as a microcontroller input to turn the circuit back off. To solve this problem, I added a smaller red pushbutton that the microcontroller monitors. If this second button is pressed, it turns everything off (including itself). The new small black pushbutton starts and stops the timer. This also allows me to eliminate the bypass switch, as I can now turn everything on (with or without the timer) and off electronically.