Hi, with this project you will be able to control the on and off of your devices between the time you want. They may be the lights at the night, water the garden, turn on a machine, etc. We will use the arduino, the LCD and the RTC 1307 to show and control the time. You can set the "ON" hour and the "OFF" hour, by 4 push buttons that let you increase or decrease the "SET POINT". Also, you will learn to make a clock with the arduino. I included fritzing schematics and a video, so you can make this project.

First, see the video to know what is all about. Use it like a guide

Step 1: Materials

-Arduino Uno

-RTC 1307 module

-LCD 16X2

-5V relay module

-10K trimpot

-1K resistor

-10K resistors x 4

-Push buttons x 4

-Breadboard, jumpers.

Step 2: Mounting the Clock

Follow the Fritzing schematic.

Connect 5v and gnd, from the arduino to their respective rails (Red 5V and Blue GND)

LCD pins to Arduino pins

1 VSS to GND

2 VDD to 5V

3 VO to pot center

4 RS to pin 2

5 RW to GND

6 EN or E to pin 3

7 D0 NC

8 D1 NC

9 D2 NC

10 D3 NC

11 D4 to pin 4

12 D5 to pin 5

13 D6 to pin 6

14 D7 to pin 7

15 A to 5V

16 K to GND by 1K resistor

The extremes of the trimpot to 5V and GND

RTC to Arduino

SDA to pin 4

SCL to pin 5

GND and 5V

Step 3: Setting the Time

Now we have to set the clock. Run the code "Set time RTC". This sketch take the Date and Time according the computer you're using (right when you compile the code) and uses that to program the RTC. If your computer time is not set right you should fix that first. Then you must press the Upload button to compile and then immediately upload.

Warning !: If you compile and then upload later, the clock will be off by that amount of time.

Then open up the Serial monitor window to show that the time has been set

Step 4: The Clock

With the time set, open and upload the sketch "Clock with RTC LCD" . The 10K trimpot is for the lcd contrast.Turn it to adjust the contrast and see the numbers clearly.

If everything works fine, you will have the clock running. See the video.

Step 5: Mounting the Timer

Now we add the push buttons and the relay. Follow the fritzing schematic.

So, you have pins 8, 9, 10 and 11 connected to gnd by 10K resistor(LOW). When you push, it will be connected to 5V (HIGH).

The relay is connected to pin 12. With the relay you can control your devices. Be careful with the maximun load of the relay!

Step 6: The Timer

Open and upload the code "Timer with on off set point" . You will see the current time, the "ON" set point and the "OFF" set point. The default "ON" and "OFF" time is 12.

The timer runs from 0 to 23 hours, and so on. Push the buttons to change the set point up and down. The timer will start immediately if it is between the setting values.If not, will wait to the "ON" hour.

This code have interesting functions that you can use in other projects. I tried to separate every function to make it clear.

- Add buttons to change settings

-Debounce buttons

-Limit of the set point or any values

- Add a clock to your project

All codes are made by me, exept:

Set the time of RTC , Adafruit data logger shield guide


I hope this tutorial is useful for you!

Nicolás Jarpa

<p>Can you use an RTC ds3231 instead? and is there a way to make settings for 18 hour and 24 on/off ?</p>
<p>Of couse, use rtc 3231 library, i don&acute;t get the second question....</p>
<p>Is there a way to have 18 hours on and 6 off preset as one repeating cycle?</p>
<p>thanks for the information.. i want ask again.. how i add some servo for that ? </p>
<p>Do you mean a servo position at specific time?</p>
<p>i have a problem.. i buy lcd with ic2.. and the lcd must sda on a4 and scl on a5.. i use arduino uno.. so the rtc1307 sda and scl dont have slot.. can you help me ? </p>
<p>A4 and A5 are I2C bus ,that means that you can connect more than 100 devices at the same time.You need to declare the direction of you lcd or/and RTC (like 0x22 or 0x27). If you don&acute;t know, there is a &quot;I2C scanner&quot;.Look for more info about I2C bus, there is a lot of examples and tutorials.Regards</p>
Can I include the date in the timer settings?
<p>Yes by modifying the code, the rtc library let you &quot;call&quot; date and time , but you will need to buid and interface (buttons ,pads) to enter the parameters.</p>
<p>do you have a link the RTC lib you are using? my version seems to have some type of conflict.</p>
<p>hi!</p><p>i need to make daily program my servo motor on arduino. for example;</p><p>23:00 at night ,it should turn right 90'; <br>8:00 at morning, it should turn left(back) 90'<br>can i use your scheme for this? how?<br>also;<br>when i need; i should turn this servo, left-right manually via internet.<br>how can i make this? any idea?</p><p><em>I appreciate any help that you can provide.</em></p><p><em><br></em></p>
<p>Hello, great project ;] why when i use arduino leonardo your sketch doesnt work(Timer_with_on_off_set_point). On arduino Uno is ok, where is difference?? And what i must to do if i want run this project without communication with PC (after verify and compile sketch on arduino)?</p>
<p>Thanks! There is some differences between UNO and Leonardo,On this project we are using SDA (A4) and SCL (A5), for the clock. Leonardo has different pins: SDA pin 2 and SCL pin 3. You can find more information on the web.On the video you can see that i am not connected to the pc.Use a suitable power supply or baterry pack and connect the plug to the power jack on the Arduino.</p>
<p>Great stuff and a beautifully clear instructable. I built this today without problems (well, except for the couple of 'dead' jumper wires that had me confused for a while). I'm hoping to learn enough from your code (reading and de-bouncing switches) to </p><p>improve some of my existing projects. Many thanks and keep 'em coming!</p>
<p>Thanks my friend! Iam glad to help you.</p>
<p>Hello friend, I first want to congratulate you for the excellent work. Although I would like to know if I can also set the minutes to have a more precise control ?. Greetings and waiting for your answer.</p>
<p>Thanks! The answer to your question is totally yes! just need to repeat the code, this time from 0 to 60 min and add the buttons. It was my first intention , but due to the space and the tons of wires, i did not . I really don&acute;t like the breadboards and now i am making &quot;shields&quot; with the projects involving many elements. I will make it soon! Regards!</p>
<p>Thanks for your quick response. Here in Venezuela life is pretty tough and universal programmers times are really expensive. So I feel the need to make one. I need to save at least 4 or 5 events per day and Saturday or a Sunday nothing happens. But I'm pretty novice at this arduino and I think this project helpful friend and I would like you to help me with that.</p>
<p>Hola amigo! Saludos desde Chile Bicampe&oacute;n XD ! Entiendo que adem&aacute;s del timer con horas y minutos, necesitas m&aacute;s de un seteo por d&iacute;a?. Tengo amigos de Venezuela y s&eacute; de su dif&iacute;cil momento. Creo que para tareas m&aacute;s complejas necesitas la ayuda de un computador.Si es as&iacute; hablaremos por interno.</p>
<p>second option is? It can be a real time switch!</p>
How many items can you have switched with this timer? I've been thinking of trying this and I believe your instructible will be of great use. I'm looking to make a controller that can control a minimum of four relays. <br><br>Thanks for taking the time and putting this together.
<p>Hi. I used only 1 relay. You can use the other pins for more relays, but you only can set one instruction. I mean, the relays will be on/off at the same time. With one relay you can control/power another relays, of course. 4 relays in the same pin it&acute;s too much load for one pin (40 mA per pin). The picture show you the consumption of the signal (not the coil). This is the lower consumption that i find in my relays. So, 4 relays exeeds 40 mA.I hope I have answered your question. Don&acute;t hesitate to ask again.Regards!</p>
<p>great project</p><p>I will helpful to my next job</p>
<p>Thanks! I am glad to help you</p>

About This Instructable




More by NicolasJ7:Arduino& Labview With 2 DS18B20  Arduino/Android Timer (with App!).Control your lights and other stuff Every Liter Counts! Arduino Water Doser "Shield" 
Add instructable to: