Arduino Timer With On/Off Set Point

89,871

147

87

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

Supplies:

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

7 People Made This Project!

Recommendations

  • Woodworking Contest

    Woodworking Contest
  • Fandom Contest

    Fandom Contest
  • IoT Challenge

    IoT Challenge

87 Discussions

0
None
rocky4ritesh

7 weeks ago

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

0
None
Tom Mac

Question 2 months 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
None
nalsur8

Question 3 months ago on Step 6

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

0
None
NicolasJ7ejaaammm

Answer 6 months ago

Check your connections. Did you set the time?

0
None
ejaaammmNicolasJ7

Reply 6 months ago

Connection are all right. Time also has been set

0
None
CorbinM5

Question 6 months ago

is it possible to do this without a 5v relay lemme know please ?

1 answer
0
None
NicolasJ7CorbinM5

Reply 6 months ago

I don´t understand your question. You just don't want to use it or want to use another device?

0
None
NicolasJ7shrina maskey

Answer 6 months ago

Yes, but it's not practical. Try a 4.7K resistor from +5v to LCD VO

0
None
NicolasJ7shrina maskey

Answer 7 months ago

Hi! You need to use the "COM" and "NO" from the relay to interrupt one line of the power supply. Watch the picture

DC Motor Relay.png
0
None
VGlorious.

Question 7 months ago

So uhhh, it didn't work for me. First off, the ON and OFF button is not functional, and then I still can't set up the clock. I already built it right too. You got any idea what's wrong?

1 answer
0
None
NicolasJ7VGlorious.

Answer 7 months ago

The circuit and the code are fine, verified by several users. Check your buttons, pulldown configuration. Did you change the code?

0
None
gagant58

11 months ago

how can i adjust on of timing on minute basis??

can anybody help me out?

anybody!!!

1 reply
0
None
NicolasJ7gagant58

Reply 11 months ago

Did you check my new instructable? Link in the intro.

0
None
hamzas83

Question 11 months ago

Anyone can help me, I am trying to design a circuit which remembers the hours of my generator and when i turn off and turn on generator LCD should display all the past hours plus current hours of generator actually I want to make this circuit to measure 50 hours of running generator so i can change the oil as per reading report.

1 answer
0
None
NicolasJ7hamzas83

Answer 11 months ago

You better get an hourmeter. You can make a simple counter code and unless you can provide constant power to your Arduino, otherwise, you will lose your data. You can use the EEPROM to save your data but if you save, let's say, every minute, you will be out of memory very soon.