This question already has an answer here:

What would be the right thing to use if I want the base of a transistor to be high for 12 hours and low for 12 hours?

I ask because I would like to make a circuit that regulates temperature in a room. To do this I am using a ntc thermistor and a ptc thermistor that I have set to trigger a fan or a heater depending on the temperature of the room, but my question is not about the thermistors. I want the room to be hotter for 12 hours and cooler for 12 hours a day and I don't know what to use to switch between two temperature control circuits. I am building this for a garden. I want the plants to have a "daytime" and a "nighttime" (quotes because the plants are indoors and receive their light from lights that this circuit will help control).

I am pretty sure I can do this with a microcontroller like an arduino, but I am curious if there is another way to do this without a microcontroller. I was thinking of a 555 timer, but I don't think resistors and capacitors exist that are big enough. Thank you for any response you might provide.


marked as duplicate by Anindo Ghosh, Leon Heller, Joe Hass, Daniel Grillo, Nick Alexeev Mar 16 '14 at 17:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ I think most thermostats for home heating systems include this function, and are nicely packaged with a display and controls... \$\endgroup\$ – Peter Bennett Mar 16 '14 at 16:13

A low tech but cheap way to do this is to use 24 hour AC power timers that are readily available at home stores. Set the timer to power on for 12 hours and off for 12 hours. You might need to use two for your application. Either analog or digital timers can be used and have the advantage of high reliability and ease of changing the time periods.


The Arduino is not a microcontroller, but a complete microcontroller board. For the purposes described, an Arduino would be overkill, while a very low-cost, basic microcontroller such as the Atmel ATtiny25 would suffice. Of course, the output pin that your code would toggle once every 12 hours, then needs to drive some switching device, such as a relay, that can actually switch the heating / cooling / lighting circuits on and off. To drive the relay, one would typically use a MOSFET or BJT controlled by the microcontroller's IO pin.

If you are not comfortable with, or for some reason constrained against, using a cheap, minimal microcontroller, there are alternatives to the 555 that can give you the 12 hour timing you need.

Assuming familiarity with the 555 timer in astable multivibrator mode, with equal duration high and low defined by an R-C combination, consider the CSS555C Micropower Timer as a replacement.

The CSS555C contains an integrated capacitor, so RC time is set merely by a resistor. Also, the IC contains a 6 decade internal programmable counter. This means, it's time constant can be set to multiples of the equivalent time constant of the 555 timer.

Duration can thus extend from microseconds to several days if needed, without impracticably large resistance values.

You will however need a microcontroller (or an Arduino board) to initially program the internal EEPROM for the counter - this can be done independently of the final timer circuit. Once programmed, the setting storage is non-volatile, so the timer can be taken out of the programming environment (e.g. breadboard) and plugged into the target circuit.

  • \$\begingroup\$ Nice to know something like that exists. \$\endgroup\$ – Passerby Mar 16 '14 at 17:37

The problem with using a timing scheme based on capacitors and resistors to control the timing period is that it is going to drift, and over days or weeks your nighttime is going to turn into daytime and vice-versa.

Even with a microcontroller solution, depending on the accuracy of the crystal on the board, you are still susceptible to drift.

The reason the clocks in your home stay accurate is that they are synchronized to the 60 Hz power, which over a day-long period is kept vary accurate (over a short time it may drift by a fraction of a Hertz).

So the best solution for you is to also use the power line as a counting source, using a AC zero crossing detector like this one. (There are also many other circuits on the web that do the the same thing.)

You can then feed it into a multiple decade counter (one feeds into the next using a carry bit) made up of inexpensive CD4017 IC's, and do a match on the output for 2592000 (number of 60 Hz cycles in 12 hours) using an 8-input NAND gate.

The output of the NAND gate feeds into a SN74HCT74 flip-flop, the output of which controls your transistor. The same matching value would be used to clear all the counters and start over for the next 12 hours.

All of the IC's are available in DIP packages making it easy to construct the circuit.


Not the answer you're looking for? Browse other questions tagged or ask your own question.