Digital Clock
A digital clock is an alternative to a traditional analogue clock. This type of clock shows numbers to display the time in a digital format, such as on a watch, phone or an alarm clock. This can be in both 12 and 24-hour formats.
A digital clock is a type of clock that displays the time digitally, as opposed to an analogy clock, where the time is indicated by the positions of rotating hands.
Digital clocks are often associated with electronic drives, but the "digital" description refers only to the display, not to the drive mechanism. The biggest digital clock is the Lichtzelt Pegler on the television tower Rhenium Düsseldorf, Germany.
Digital, representing a finger, implies a thing that can be counted on fingers, which indicates a number.
History of Digital Clock:-
The first digital pocket watch was the invention of Austrian engineer Josef Pallweber who created his "jump-hour" mechanism in 1883. Instead of a conventional dial, the jump-hour featured two windows in an enamel dial, through which the hours and minutes are visible on rotating discs. The second hand remained conventional. By 1885 Pallweber mechanism was already on the market in pocket watches by Cortébert and IWC; arguably contributing to the subsequent rise and commercial success of IWC. The principles of Pallweber jump-hour movement had appeared in wristwatches by the 1920s (Cortébert) and are still used today (Chrono Swiss Digester). While the original inventor didn't have a watch brand at the time, his name has since been resurrected by a newly established watch manufacturer.
How to Make Digital Clock using Arduino Uno
How to design a digital clock using Arduino
In the past to calculate the time the analogue clocks were used which had a dial having numbers ranging from 1 to 12 and the dial had needles. But now the digital clocks are mostly used as they are compact in size, more accurate and less power consuming. To understand the working of the digital clock we have created a digital clock using Arduino Uno.
Today I'll show you How to make Digital Clock using Arduino and LCD but without RTC Module.
Code and Circuit Link is at the last.
If you like this project do comment on YouTube video, and do not forget to subscribe my channel, link is below:-
https://studio.youtube.com/channel/UCaXI2PcsTlH5g0et67kdD6g
If you have any doubt regarding this project, you can Contact me from below.
If you have any suggestions or project idea, kindly reach out to my channel or Telegram me at above no.
You're most welcome.
Parts List :-
Steps to make this project:
1. Buy components like Arduino Nano, Breadboard, LCD display, 10K potentiometer, Push buttons etc from above links.
2. Place Arduino Nano, LCD display and Push Buttons on Breadboard.
3. Do connections according to Circuit Diagram.
4. Upload the code.
5. Set time according to you.
Note: This project Digital Clock is without RTC Module, You have to adjust time when Arduino Nano loses power.
Your Project is Ready.....
Circuit Diagram:-
Just Copy the code from below and Paste it in Arduino IDE
// https://www.youtube.com/channel/UCaXI2PcsTlH5g0et67kdD6g //
// Arduino Digital Clock //
// By MOHD SOHAIL //
#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);
int s,m,h,a,d,state,state1,state2,dg,cnt;
// the 8 arrays that form each segment of the custom numbers
byte bar1[8] =
{
B11100,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11100
};
byte bar2[8] =
{
B00111,
B01111,
B01111,
B01111,
B01111,
B01111,
B01111,
B00111
};
byte bar3[8] =
{
B11111,
B11111,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111
};
byte bar4[8] =
{
B11110,
B11100,
B00000,
B00000,
B00000,
B00000,
B11000,
B11100
};
byte bar5[8] =
{
B01111,
B00111,
B00000,
B00000,
B00000,
B00000,
B00011,
B00111
};
byte bar6[8] =
{
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111
};
byte bar7[8] =
{
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00111,
B01111
};
byte bar8[8] =
{
B11111,
B11111,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000
};
void setup()
{
// assignes each segment a write number
lcd.createChar(1,bar1);
lcd.createChar(2,bar2);
lcd.createChar(3,bar3);
lcd.createChar(4,bar4);
lcd.createChar(5,bar5);
lcd.createChar(6,bar6);
lcd.createChar(7,bar7);
lcd.createChar(8,bar8);
state=1;
state1=1;
state2=1;
// sets the LCD's rows and colums:
lcd.begin(16, 2);
pinMode(8,INPUT_PULLUP);
pinMode(9,INPUT_PULLUP);
pinMode(10,INPUT_PULLUP);
s=0;
m=0;
h=0;
a=0;
}
void custom0(int col)
{ // uses segments to build the number 0
lcd.setCursor(col, 0);
lcd.write(2);
lcd.write(8);
lcd.write(1);
lcd.setCursor(col, 1);
lcd.write(2);
lcd.write(6);
lcd.write(1);
}
void custom1(int col)
{
lcd.setCursor(col,0);
lcd.write(32);
lcd.write(32);
lcd.write(1);
lcd.setCursor(col,1);
lcd.write(32);
lcd.write(32);
lcd.write(1);
}
void custom2(int col)
{
lcd.setCursor(col,0);
lcd.write(5);
lcd.write(3);
lcd.write(1);
lcd.setCursor(col, 1);
lcd.write(2);
lcd.write(6);
lcd.write(6);
}
void custom3(int col)
{
lcd.setCursor(col,0);
lcd.write(5);
lcd.write(3);
lcd.write(1);
lcd.setCursor(col, 1);
lcd.write(7);
lcd.write(6);
lcd.write(1);
}
void custom4(int col)
{
lcd.setCursor(col,0);
lcd.write(2);
lcd.write(6);
lcd.write(1);
lcd.setCursor(col, 1);
lcd.write(32);
lcd.write(32);
lcd.write(1);
}
void custom5(int col)
{
lcd.setCursor(col,0);
lcd.write(2);
lcd.write(3);
lcd.write(4);
lcd.setCursor(col, 1);
lcd.write(7);
lcd.write(6);
lcd.write(1);
}
void custom6(int col)
{
lcd.setCursor(col,0);
lcd.write(2);
lcd.write(3);
lcd.write(4);
lcd.setCursor(col, 1);
lcd.write(2);
lcd.write(6);
lcd.write(1);
}
void custom7(int col)
{
lcd.setCursor(col,0);
lcd.write(2);
lcd.write(8);
lcd.write(1);
lcd.setCursor(col, 1);
lcd.write(32);
lcd.write(32);
lcd.write(1);
}
void custom8(int col)
{
lcd.setCursor(col, 0);
lcd.write(2);
lcd.write(3);
lcd.write(1);
lcd.setCursor(col, 1);
lcd.write(2);
lcd.write(6);
lcd.write(1);
}
void custom9(int col)
{
lcd.setCursor(col, 0);
lcd.write(2);
lcd.write(3);
lcd.write(1);
lcd.setCursor(col, 1);
lcd.write(7);
lcd.write(6);
lcd.write(1);
}
void printNumber(int value, int col) {
if (value == 0) {
custom0(col);
} if (value == 1) {
custom1(col);
} if (value == 2) {
custom2(col);
} if (value == 3) {
custom3(col);
} if (value == 4) {
custom4(col);
} if (value == 5) {
custom5(col);
} if (value == 6) {
custom6(col);
} if (value == 7) {
custom7(col);
} if (value == 8) {
custom8(col);
} if (value == 9) {
custom9(col);
}
}
void loop()
{
if(!digitalRead(8)&state==1){
cnt++;
state=0;
if(cnt>3){
cnt=0;
}
}else if(digitalRead(8)&state==0){
state=1;
}
if(!digitalRead(9)&&state1==1){
dg=1;
state1=0;
}else if(digitalRead(9)&state1==0){
state1=1;
}
if(!digitalRead(10)&&state2==1){
dg=-1;
state2=0;
}else if(digitalRead(10)&state2==0){
state2=1;
}
switch(cnt){
case 1:
m=m+dg;
dg=0; if(m>59){
m=59;}
if(m<0){
m=0;}
break;
case 2:
h=h+dg;
dg=0;if(h>11){
h=11;}
if(h<0){
h=0;}
break;
case 3:
if(dg==1){
a=1;
dg=0;}
if(dg==-1){
a=0;
dg=0;}
break;
}
if(s>59){
s=0;
m++;
if(m>59){
m=0;
h++;
if(h>11){
h=0;
a=!a;
}
}
}
d=h%10;
printNumber(d, 3);
d=h/10;
printNumber(d, 0);
d=m%10;
printNumber(d, 10);
d=m/10;
printNumber(d, 7);
lcd.setCursor(14, 0);
if(a){
lcd.print("AM");
}else{
lcd.print("PM");
}
if(cnt==0){
s++;
lcd.setCursor(6, 0);
lcd.print(" ");
lcd.setCursor(6, 1);
lcd.print(" ");
delay(500);
lcd.setCursor(6, 0);
lcd.print(".");
lcd.setCursor(6, 1);
lcd.print(".");
delay(500);
}
}
0 Comments