# How can I turn on and off a switch every 20 minutes?

I want to make the above switch which will stay on for 20 minutes and then off for 20 minutes. This should be continuous. Actually, I want to place this switch for my air conditioner which I do not want to run the whole night but off itself every 20 minute interval and restart after 20 minutes. This will save my electricity by half.. since the thermostat function of the air conditioner is not of much use and also I do not want my appliance to run for the whole night.

The device I'm going to switch takes between 5 and 15 Amps circa.

• Before Olin comes...use a microcontroller and relays – clabacchio Jun 8 '12 at 12:17
• I have an awesome idea: use a 555 to generate the clock for a PIC 10F200 :) – clabacchio Jun 8 '12 at 14:11
• @clabacchio - No the 10F200 can't work on an external clock. What you could do is let the 555 give interrupts upon which the 10F200 toggles its output. – stevenvh Jun 8 '12 at 14:38
• @stevenvh: gosh my fault :) no, no, too simple :) – clabacchio Jun 8 '12 at 14:39
• Just as an aside - there isn't actually any requirement for the interval to be either accurate in time or duty cycle. I am sure 1220s on, 1180s off would be fine as well. It just has to be approximately 50% duty with a long enough cycle to not cause rapid cycling issues. – Cybergibbons Jun 8 '12 at 14:47

Oh dear no. Please use a microcontroller.

The Microcontroller

Look for one that has a timer (I don't think I've ever seen one that doesn't). Your timer will overflow at a periodic, predictable interval (which you will set up). Divide 20 minutes by that interval and you will know the number of timer overflows needed to "count" to 20 minutes. Each time the timer interrupt fires, increment a variable. When the variable gets to the previously calculated value, switch whatever switch/relay/FET you have for controlling the circuit (see below for that problem). This solution makes changing the on/off time relatively easy since all you'll be changing is your increment variable max count, rather than having to change the caps & resistors. You could even have different on/off times if you decide you want that later on, for example: On for 5 mins/off for 15.

The Switch

From what you say, you're looking at 5-15 Amps of current. The trouble you'll find is that the "inrush current" (which is the sudden surge of current you will get right after the switch is closed). There are many switches/relays out there that can easily handle 15A of constant current (steady state), but you'll find repeated switching will make them fail because in reality they see a much higher inrush current. So you'll need to find one that can handle, not just 15A, but whatever inrush current your circuit has. There are two general categories of switches:

1. Mechanical - electro-mechanical relays
2. Solid State - FETs, Triacs, solid-state relays

Of those two, for 15A, I recommend the second category because the mechanical relays will often "arc" when closing to switch on which, over time, produces a buildup on the terminals and they will ether fuse closed (always on) or never be able to completely close (never turn on) if they are switched too often. Usually you can get a good power-MOSFET or solid-state relay that can properly handle and dissipate the heat associated with the surge of inrush current. You'll easily find a circuit for how to drive a MOSFET switch from one of the pins on the microcontroller by simply Googling.

Find a motor that rotates once every 40 minutes, make a semicircular cam and fit to the motor spindle. Get a microswitch that can handle the required voltage/current and mount it so that the cam activates the microswitch for half of the rotation period of the motor. Use the microswitch to control the power to the device and Robert is your father's brother.

@skyler commented to another answer that you would have to use gears to get the motor to turn this slowly. That is true, but I have used a motor with built in reduction gearing that produced one rotation per day. This pressed a microswitch each way to activate the watering system in my greenhouse.

If you can cope with 30 minutes on/30 minutes off then an old clock with the cam replacing the minute hand will work well.

• Are you serious? – clabacchio Jun 8 '12 at 13:31
• @clabacchio But if it's a joke, It's a very good one :-) – m.Alin Jun 8 '12 at 13:34
• @m.Alin: definitely it's not a joke :( It's a 17th century-style answer – clabacchio Jun 8 '12 at 13:35
• +1 for the "out of the box" thinking. Old appliances used something similar. If you could rip the timing mechanism out of something and re-purpose it then there might be something to this. I wouldn't build one from scratch, however. A Microcontroller would be better if you are starting from scratch. – user3624 Jun 8 '12 at 13:59
• @m.alin - It is an ELECTRO-mechanical solution. There are many questions here about motors, enclosures, PCBs, connectors and other only loosely electronic devices. The OP posted a question about how to solve a problem. This is a perfectly workable solution to that problem. Just as not every tool is a hammer, not every problem requires a processor and software. – uɐɪ Jun 12 '12 at 11:13

As clabacchio noted in a comment, I would solve this problem with a microcontroller driving a relay. 20 minutes on and 20 minutes off is a very long time for a 555 timer, or most any analog electronics.

A PIC 10F200 can do this job easily. All you need is the PIC, which comes in a SOT23 package, and a single bypass cap. That gets you a digital output that is high for 20 minutes, then low for 20 minutes. The circuitry to drive a relay is the same from there, whether the on/off signal is produced by a 666 555 timer, a microcontroller, or some other harebrained scheme.

• You do have a keyboard shortcut to type "PIC 10F200", don't you? – stevenvh Jun 8 '12 at 13:41

If you are familiar with microcontrollers, then this is an easy job for something like a PIC10/12F as mentioned. Write the code in 5 mins, solder a few wires together and you're done.

However, it is quite possible you may not be, so:
A 555 or similar will do the trick, but as clabacchio mentions you will have less control (and accuracy) of the timing. It will be very rough.
That said I imagine this application does not require really tight timing though so a 555 just may be suitable for your needs.
So you grab your 555, read the datasheet and set it up for the correct timing. Then connect the output to a suitable relay rated to handle above the maximum current expected (the 555 output can source/sink up to 200mA which should be fine for most relays) For more accuracy but still no micro, some reasonably simple 7400/4000 series logic involving e.g a 32768 Hz crystal oscillator, a few counters to divide the frequency down would be cheap and pretty easy to rig up if you have some experience with these things.

I'm sure there will be some timer chip more convenient than the 555 out there if you have a look at Farnell, Mouser, Rs, etc. Some 32Khz crystal based IC with an adjustable output pulse would be what you want, although many will need to be controlled via SPI/I2C, so you are back to micros again :-)

I don't think the 'use a microcontroller' answer is very usefull to Tushar. The good-old 555 won't do 20 minutes, even his CMOS simbling probably won't.

But there is another oldie that some people seem to forget: the CD4060 oscillator + 14 stage binary counter. Check for instance http://www.coolcircuit.com/circuit/timer_4060/index.html for a circuit. It even shows a 20 minutes output :)

• Why won't the 555 do 20 minutes? I'm curious because I've done something very similar myself ... except my 555 drives an LED over 45 minutes on, and a slightly lesser duration off. – Everyone May 27 '13 at 18:50

If you have an item that oscillates on fixed periods, for example, a fish pond decoration:

which you can use to drive a gearbox connected to the pivot of the bamboo, which at every rotation of the gearbox, it depresses the power button on the remote control.

<insert-rube-goldberg-jokes-here>

There are many possible alternative oscillators if you don't have a fish pond, for example, a grandfather clock or parts taken from your old alarm clock.

It would be a sight to watch, and something to add to your geek cred.

• Come on guys, serious! – clabacchio Jun 8 '12 at 18:31
• I don't think this deserves downvotes! It is in the spirit of other answers. – Cybergibbons Jun 8 '12 at 19:36
• I saw the same design in some water park. The basket was huge ! – user924 Jun 8 '12 at 22:15
• @Cybergibbons The answer doesn't have anything to do with electrical engineering – m.Alin Jun 8 '12 at 22:34
• @m.Alin, but it does have everything to do with engineering. Sometimes the right answer is not precisely what the customer asked for, but what the customer needs. This answer is slightly deficient on practical measures, however. Making a bamboo water sculpture do useful work is an exercise for advanced students. Not to mention switch 15A AC with water... ;-) – RBerteig Jun 8 '12 at 23:23

Use a 555 timer chip, a capacitor and 2 resistors. Wire these up with a relay on the output, so when the chip is on, the relay conducts electricity from point a to b, and when off, it doesent. Google search 50 555 circuits and it should be the first. This contains many circuits and one should fit your need, at least if modified. The capacitor and resistor values should vary.

The 555 timer is a cheap chip, which can be gotten at most electronic stores (even RadioShack!!!!!) http://www.csgnetwork.com/ne555timer2calc.html use the calc on the link to calculate on and off time and what capacitors and resistors to use

• 555 seems the most immediate solution, but it's better to use a microcontroller in those cases, because it gives you more control over the timing, and it's easier to reconfigure – clabacchio Jun 8 '12 at 12:59
• @Ian: Accuracy isn't the issue, but the long time constants are. Go figure out the resistor and capacitor values required for a 555 timer to do a 40 minute period, then compute the currents and compare them to leakage values. – Olin Lathrop Jun 8 '12 at 13:35
• @Ian - how can it be overkill? It uses less components than the 555: just one. The 555 is dead, today it's microcontrollers. Less parts, more accurate, better reproducibility. Once you used one you don't want to go back. – stevenvh Jun 8 '12 at 13:38
• @Cybergibbons, do you have an actual range for the AVRs? 555 timers are designed in such a way that all measurements are relative, they are functional in many applications due to supply voltage invariance. I am not trying to say it is the best solution, just that you may not realize how broad a supply it accepts. In this case I may not realize how broad a supply an AVR accepts. – Kortuk Jun 8 '12 at 15:24
• 0.7-5.5V is the widest, with 1.8-5.5V being typical. This, relatively, isn't much less than the typical 4.5-16V that a LM555 needs. What happens to a 555 with a long time constant as the supply voltage drifts during the cycle? – Cybergibbons Jun 8 '12 at 15:35

## protected by KortukJun 9 '12 at 11:32

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).