Digital Clock Circuit Making

by ROBOTICS in Circuits > Arduino

352 Views, 5 Favorites, 0 Comments

Digital Clock Circuit Making

8.PNG
12.PNG
1.PNG
FK539VDKV58WSJK.png

This is circuit which is there in a digital wall clock . I have designed it using tinkerCAD software. This helps you to know what is there in your digital clock .

This is a easy working model for beginners of Robotics.

This is my third working model .


Supplies

2.PNG
3.PNG
7.PNG
4.PNG
5.PNG
6.PNG

1} Bread Board

2} Arduino

3} LCD 16 x 2

4} Potentiometer

5} Resistor

6} Connecting Wires


These are the materials required to make the circuit of a digital clock .

Arrange of Arduino,Bread Board and Potentimeter.

9.PNG

Arrange Arduino , Bread Board and Potentiometer as shown in the image

Connecting LCD

7.PNG

The second step is to connect LCD to Bread Board

Now follow the above image to connect LCD

Connecting Resistor

5.PNG
11.PNG

Your third step is to connect Resistor .

Connect Resistor to [ j-19] to minus [-]

You can also do it by the above image

Connecting Wires

6.PNG
1.PNG

1. Connect the 5V pin from Arduino Uno to the positive rails of the breadboard

2. Connect the ground (GND) pin from Arduino Uno to the negative rails of the breadboard

3. Place the potentiometer on the breadboard, and connect terminals 1 and 2 of the potentiometer to the positive and negative rails of the breadboard, respectively.

4. Connect the ground (GND) pin of the LCD to the negative rail of the breadboard.

5. Connect the power (VCC) pin of the LCD to the positive rail of the breadboard.

6. Connect the contrast (V0) pin of the LCD to the wiper pin of the potentiometer through the breadboard.

7. Connect the Register Select (RS) pin of the LCD to the digital pin 12 of the Arduino through the breadboard.

8. Connect the Read/Write (RW) pin of the LCD to the negative rail of the breadboard.

9. Connect the Enable (E) pin of the LCD to the digital pin 11 of the Arduino through the breadboard.

10. Data pins DB0 to DB3 of the LCD are not connected to anything because we are using 4-wire mode (only four pins are connected to the Arduino).

11. Data pins DB4 to DB7 of the LCD are connected to the Arduino digital pins 5 to 2, respectively.

12. LED Anode of the LCD is connected to the positive rail of the breadboard through 220 ohm resistor, and LED Cathode of the LCD is connected to the negative rail of the breadboard.


Follow these methods for connecting wires.




Coding

Coding is the important part in Robotics

If you are designing this model in thinkerCAD Software than use this coding

Click on the "Code" option available in the Tinkercad and write the following program in it.


#include LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int ss,mm,hh,MM,DD,YYYY,AP;

int k=0;

void setup()

{

Serial.begin(9600);

lcd.begin(16,2);

}

void loop()

{

/*After asking for details k=1 so never asks for instructions again*/

if(k<=0)

{

/*Details() - Asks for time and date*/

Details();

}

ss=ss+1;

if(ss==60)

{

ss=0;

mm=mm+1;

if(mm==60)

{

mm=0;

hh=hh+1;

if(hh==12)

{

AP=AP+1;

printTime2();

/*Day only advances when going from PM to AM*/

if(AP%2==0)

{

DD=DD+1;

}

// assumes that all months have 28 days

if(DD==28)

{

DD=1;

MM=MM+1;

if(MM==13)

{

MM=1;

YYYY=YYYY+1;

}

}

}

if(hh==13)

{

hh=1;

}

}

}

/*printTime2 - adds one second and displays time on LCD display*/

printTime2();

}

void line()

{

Serial.println("");

}

void Details()

{

Serial.println("Enter current hour:");

while(Serial.available()==0);

hh=Serial.parseInt();

/*line() - inserts blank line into serial monitor to separate data*/

line();

Serial.println("Enter current minute:");

while(Serial.available()==0);

mm=Serial.parseInt();

line();

Serial.println("Enter current second:");

while(Serial.available()==0);

ss=Serial.parseInt();

line();

Serial.println("Enter AM(0) or PM(1)");

while(Serial.available()==0);

AP=Serial.parseInt();

line();

Serial.println("Enter current month:");

while(Serial.available()==0);

MM=Serial.parseInt();

line();

Serial.println("Enter current day:");

while(Serial.available()==0);

DD=Serial.parseInt();

line();

Serial.println("Enter current year:");

while(Serial.available()==0);

YYYY=Serial.parseInt();

line();

k=k+1;

}

void printTime(int x)

{

if(x<=9)

{

lcd.print("0");lcd.print(x);

}

else

{

lcd.print(x);

}

}

void printTime2()

{

lcd.setCursor(0,0);

/*printTime - places "0" in front of single digit numbers*/

printTime(hh); lcd.print(":");

printTime(mm); lcd.print(":");

printTime(ss); lcd.print(" ");

/*if AP is odd, it reads AM

if AP is even, it reads PM*/

if(AP%2==0)

{lcd.print("AM");}

if(AP%2==1)

{lcd.print("PM");}

lcd.setCursor(0,1);

printTime(MM); lcd.print("/");

printTime(DD); lcd.print("/");

printTime(YYYY);

delay(1000);

}