Arduino Timer With On/Off Set Point

131,039

164

103

Introduction: Arduino Timer With On/Off Set Point

Edited 05-02-2018 New Timers! hours,minutes, seconds, eeprom. Please visit:

https://www.instructables.com/id/Arduino-Ultra-Meg...

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, watch 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

10 People Made This Project!

Recommendations

  • Hand Tools Only Challenge

    Hand Tools Only Challenge
  • Modify It Speed Challenge

    Modify It Speed Challenge
  • Remix Contest

    Remix Contest

103 Discussions

0
Tobiasmx
Tobiasmx

Question 9 months ago

quick question, Can I use the RTC 1307 at24c34 without having to modify the code? I can get them real cheep local but nobody has the RTC 1307 without the memory. I have looked at your other timer version using the DS3231which I love also, but my application only needs 1 cycle per day on for 3 hours and off until the next day same time again so this is perfect. I see Marielle. Magbaua made the time with the at24c34 I can tell from her picture. Just need to know if the code stays the same. Thanks and great work

0
Tobiasmx
Tobiasmx

Answer 8 months ago

update: RTC 1307 ar24c34 works fine no issues.

1
FarhanN19
FarhanN19

11 months ago

hi,
is it possible to run this timer circuit entirly on c programming??
i need to run it on c programming. can u help

0
NicolasJ7
NicolasJ7

Reply 10 months ago

I'm rusty on C programming, but what's your goal?

0
FarhanN19
FarhanN19

Reply 10 months ago

my goal is to run the same project with c programming. im also weak in c programming. thats why facing problem.
setup is done exactly this way.
btw thanks for ur response ❤️❤️

0
nalsur8
nalsur8

Question 1 year ago on Step 6

Hi, what about replace the relay to servo motor? what about the coding?

0
miginstruments
miginstruments

Answer 1 year ago

you can use Servo Library.

0
sampath.subha
sampath.subha

Question 1 year ago

Hi Nicolas,
I would like to extend this to six relays. Hope this should be possible. If "yes", then can you guide me with the modifications to be done in the code and also which are the additional pins that can be used to achieve this. I am an absolutely new on arduino, hence the question. Thanks
Sampath

0
miginstruments
miginstruments

Answer 1 year ago

You can add, provided you have pins left for connecting six relays on the controller board. If no, then you can use Mega, there you ll find enough pins. But I cannot say about how to create six different intervals unless I work on the code at least for once.

1
NicolasJ7
NicolasJ7

Answer 1 year ago

Did you include the rtc library?

0
rocky4ritesh
rocky4ritesh

1 year ago

sir can we replace rtc1307 to any other like ds3231
if yes show me the connection

0
NicolasJ7
NicolasJ7

Reply 1 year ago

Yes, you can. Look at the rtc library and set the time. Then you have to change the variables ( like RTC instead of rtc). Watch my other timer with the 3231, link in the intro.

0
Tom Mac
Tom Mac

Question 1 year ago

Hi is there a way to set multiple time slots to operate a switch several times within a given 24 hour period? Thanks for great post.

0
NicolasJ7
NicolasJ7

Answer 1 year ago

Yes, look the first link in the intro

0
JacobT104
JacobT104

Question 1 year ago

Hi sir, when uploading my set time code in the COM3 window where it shows the clock running the time I get a bunch of ?????and box symbols almost like it doesn’t recognise the language. Any suggestions on any errors I have made ?

0
NicolasJ7
NicolasJ7

Answer 1 year ago

Do you mean the rtc settings on the serial port or the lcd? check the baud rate

0
ejaaammm
ejaaammm

Question 1 year ago

Hi sir. I tried but this happen

IMG_2365.JPG