How to Make a Arduino Digital Clock

58,593

48

91

Introduction: How to Make a Arduino Digital Clock

About: I am an electronic hobiest and computer science engineer . Who loves and enjoys making cool projects.

Digital clocks are one of the great invention in the field of science.

Have you ever wondered "How to make your own digital clocks , just like in movies! "????

Well i have also spent ,my childhood in a dream to built my very own digital clock.. so i built one for my self ...

And am going to show you, How you can built an amazing digital clock with little ease and little components all by yourself....

I have used 4 7 segment common anode display to display the digits, 3 SPDT switches , which i took apart from an old mouse, some wires and an arduino. we can set the time holding the adjust key and pressing the minute or hour key to change the minute or the hour to our need..!

So Lets get started...!

Step 1: Components Required

Here the Components that you will Require :

1. An Arduino uno.

2. 4 7 segment common anode displays (if you have a 4 digit seven segment , don't worry the circuitry is same for both of them).

you can buy them from snapdeal , they are great ! i would recommend them from the site.

3. 3 spdt Switches (which i scavenged from an old mouse ).

4.some wires and jumper wires (any one will do!).

5. A breadboard.

6. 4 1kohm resistors.

Step 2: Wiring the Displays in the Breadboard!

Make the connections as shown in the picture above.. its quite simple.!

Take care of the connections , as coz there are too many wires you might get confuse.

Remmenber All a,b,c,d,e,f,g,dot segments of 4 displays are connected together.... and the com of every display i.e 3 and 8 are connected together with the resitors...

Do not worry!! , go slowly,and have some patience , you can do it.

Step 3: Adding the Resistors and the Keys

Attach 1kohm resistor with each com of the displays ... as shown in the figure..!

Add the Spdt switches or if you have push on buttons that would be great !...

Step 4: Connecting to Arduino

Now the connections are done for the display and the switches ... now time is to connect them to the brain..

it is simple..

For segment pins!

a to pin 2

b to pin 3

c to pin 4

d to pin 5

e to pin 6

f to pin 7

g to pin 8

dot to pin 9

For display pins

display 1 to pin 10

display 2 to pin 11

display 3 to pin 12

dispaly 4 to pin 13

now for the keys

key 1 which is the adjust switches ...

key 2 and key 3 are hour changing and minute changing switches..

we have to hold the adjust key1 and press the desire key to change the hour or the minute..!

see the pic above for the connection for the keys .. we have used the analog pins and used them as digital input pins... yes thats true we can use them as digital i/o pins too..

Step 5: Adding the Code!!!!

Now the most cool part ... writing and adding the code to the arduino....

I have attached the code and the time library file .. for calculating the time and displaying it....

In the code the hour() function tells us the hour, and the minute() function the minute , from the time we have switched on the board. the time fades dies when the power to the board is cut of.. and it starts again from 00:00 every time...

Also i have attached a 12 hour format code too. It just uses hourFormat12() function to get the 12 hr format.

By default the Time library returns 24hr formated time.

Note:

Please add the Time Folder in Time.zip, in your Arduino's libraries folder.

eg in my system:

C:\Program Files (x86)\Arduino\libraries


Do feel flexible in changing the code for your needs ... and if you have some quarries feel free to ask.

Have fun making it...

note: I have updated the Time.zip file as it was deprecated in newer versions of Arduino IDE.

4 People Made This Project!

Recommendations

  • Pocket-Sized Speed Challenge

    Pocket-Sized Speed Challenge
  • Super-Size Speed Challenge

    Super-Size Speed Challenge
  • Audio Challenge 2020

    Audio Challenge 2020

91 Discussions

0
alokmondal8363
alokmondal8363

Question 2 months ago on Step 4

The code for common anode & common cathode are same or different? I made a common negative seven segment display, the circuit diagram same or differen?

0
S0NSU2LUK
S0NSU2LUK

Question 5 months ago

Merhaba, ben projeyi gerçekleştirdim fakat kodda hour hatası alıyorum. acaba kodu düzenli bir şekilde atar mısınız?

0
ITSNOUSE
ITSNOUSE

Answer 4 months ago

Kodunuzun başına şunu yazın
#include <TimeLib.h>

0
Bilal530
Bilal530

Question 2 years ago

sir please can u tell me how i can solve this error i have added the time folder to the arduino/libraries and i also read all answers to this question i tried every single thing you told in the answers but it is still having a same error

please sir help me out as early as possible

44.PNG
0
gassergaming
gassergaming

Answer 10 months ago

ok witer you time in min and hour

0
S0NSU2LUK
S0NSU2LUK

Reply 5 months ago

benimle de paylaşır mısın?

0
alqayadhi700393016
alqayadhi700393016

Reply 7 months ago

ME too i face the same problem
what i have to do ?

1
crownyosa
crownyosa

6 months ago

i only have common cathode 7 segment display. what kind of changes would it do to the code?

3
AkinM3
AkinM3

6 months ago

Good evening sir
Please I need ardiuno for my programming, how can I get it. Tnks

0
Shaikh Muhammad
Shaikh Muhammad

Question 7 months ago

Please help me with Arduino nano, How can I configure that which pin is for which connection of seven segment display?, I have checked 2 time all connections are according to your schematic, thanks in advance

0
sukh.gjgs
sukh.gjgs

1 year ago on Step 5

Hello, I have the error while compiling the code so please solve it

Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\gj\Downloads\final_clock_arduino_12hr\final_clock_arduino_12hr.ino: In function 'void loop()':

final_clock_arduino_12hr:59: error: 'hour' cannot be used as a function

int hour = hour();

^

final_clock_arduino_12hr:60: error: 'hr' was not declared in this scope

int timp = ( (hr>12)?(hr%12):hr)*100+minute();

^

final_clock_arduino_12hr:60: error: 'minute' was not declared in this scope

int timp = ( (hr>12)?(hr%12):hr)*100+minute();

^

C:\Users\gj\Downloads\final_clock_arduino_12hr\final_clock_arduino_12hr.ino: In function 'void set_time()':

final_clock_arduino_12hr:80: error: 'minute' cannot be used as a function

byte minute = minute();

^

final_clock_arduino_12hr:81: error: 'hour' cannot be used as a function

byte hour = hour();

^

final_clock_arduino_12hr:85: error: 'minutes' was not declared in this scope

minutes1=minutes;

^

final_clock_arduino_12hr:86: error: 'hours' was not declared in this scope

hours1=hours;

^

final_clock_arduino_12hr:131: error: 'setTime' was not declared in this scope

setTime(hours,minutes,0,0,0,0);

^

exit status 1

'hour' cannot be used as a function

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

0
KarimH30
KarimH30

Reply 1 year ago

wrong code!

0
ĐôngD
ĐôngD

Reply 1 year ago

you add this line for your code #includen <TimeLib.h>

0
malphoy
malphoy

Question 1 year ago

Hello! I did the same design, however using red leds high brightness, same connection of the common anode display scheme. It worked perfectly, Thanks!
But I came across a problem ... I set the hour and minute by my wrist watch, I left it on all day. Already at nightfall the difference was 5 minutes of delay.
Can anyone tell me the cause?
1
dancopy
dancopy

Answer 1 year ago

Did you make all the connections correctly, including the GNDs?

0
malphoy
malphoy

Reply 1 year ago

yea!!!

1
SefW
SefW

1 year ago

Hi Madrajib you say you used common anode 7 segment but you show us a common cathode 7 segment because a common anode has the vcc on the com and a common cathode has gnd on the com

common-anode-vs-common-cathode-equivalent-circuit_orig.png
0
anandhis
anandhis

1 year ago

can someone explain me the code fully?
why is the variable'i' given a value of 20 and why "timp=hours*100+minutes ???
I also wanted to do for seconds and can someone tell the code for that.
Thanku