Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

instructables

Digital Clock Using Tinkercad

by veerapec2012

Tinkercad is one of the best software tools for 3D class="supplies-heading">Supplies: Arduino Uno R3
modeling and simulating the circuits. I have created a
Digital Clock circuit using Tinkercad. I have used Arduino LCD 16x2
Uno R3, LCD 16x2, Potentiometer and a 220-ohm resistor
for making the circuit. I used a simple sketch, which is Potentiometer
attached and explained in this instructable. I ran the
sketch and found my digital clock working ne after and a 220-ohm resistor
setting the present time and date using serial monitor.

Step 1: Drag and Drop the Components to the Workspace

Create a circuit project in Tinkercad after login using your account details. Drag and drop the components mentioned in
the supplies to the workspace. You can also use the search bar for nding the required components, which are available
next to the workspace in the right hand side.

Digital Clock Using Tinkercad: Page 1


Step 2: Circuit Diagram and Connection Procedure

1. Connect the 5V pin from Arduino Uno to the positive digital pin 12 of the Arduino through the breadboard.
rails of the breadboard
8. Connect the Read/Write (RW) pin of the LCD to the
2. Connect the ground (GND) pin from Arduino Uno to negative rail of the breadboard.
the negative rails of the breadboard
9. Connect the Enable (E) pin of the LCD to the digital pin
3. Place the potentiometer on the breadboard, and 11 of the Arduino through the breadboard.
connect terminals 1 and 2 of the potentiometer to the
positive and negative rails of the breadboard, 10. Data pins DB0 to DB3 of the LCD are not connected
respectively. to anything because we are using 4-wire mode (only
four pins are connected to the Arduino).
4. Connect the ground (GND) pin of the LCD to the
negative rail of the breadboard. 11. Data pins DB4 to DB7 of the LCD are connected to
the Arduino digital pins 5 to 2, respectively.
5. Connect the power (VCC) pin of the LCD to the
positive rail of the breadboard. 12. LED Anode of the LCD is connected to the positive
rail of the breadboard through 220 ohm resistor, and
6. Connect the contrast (V0) pin of the LCD to the wiper LED Cathode of the LCD is connected to the negative rail
pin of the potentiometer through the breadboard. of the breadboard.

7. Connect the Register Select (RS) pin of the LCD to the

Step 3: Programming the Digital Clock

Click on the "Code" option available in the Tinkercad and int k=0;
write the following program in it.
void setup()
#include LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
{
int ss,mm,hh,MM,DD,YYYY,AP;
Serial.begin(9600);

Digital Clock Using Tinkercad: Page 2


lcd.begin(16,2); if(AP%2==0)

} {

void loop() DD=DD+1;

{ }

/*After asking for details k=1 so never asks for // assumes that all months have 28 days
instructions again*/
if(DD==28)
if(k<=0)
{
{
DD=1;
/*Details() - Asks for time and date*/
MM=MM+1;
Details();
if(MM==13)
}
{
ss=ss+1;
MM=1;
if(ss==60)
YYYY=YYYY+1;
{
}
ss=0;
}
mm=mm+1;
}
if(mm==60)
if(hh==13)
{
{
mm=0;
hh=1;
hh=hh+1;
}
if(hh==12)
}
{
}
AP=AP+1;
/*printTime2 - adds one second and displays time on
printTime2(); LCD display*/

/*Day only advances when going from PM to AM*/ printTime2();

Digital Clock Using Tinkercad: Page 3


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

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

{ MM=Serial.parseInt();

Serial.println(""); line();

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

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

{ DD=Serial.parseInt();

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

while(Serial.available()==0); Serial.println("Enter current year:");

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

/*line() - inserts blank line into serial monitor to separate YYYY=Serial.parseInt();


data*/
line();
line();
k=k+1;
Serial.println("Enter current minute:");
}
while(Serial.available()==0);
void printTime(int x)
mm=Serial.parseInt();
{
line();
if(x<=9)
Serial.println("Enter current second:");
{
while(Serial.available()==0);
lcd.print("0");lcd.print(x);
ss=Serial.parseInt();
}
line();
else
Serial.println("Enter AM(0) or PM(1)");
{
while(Serial.available()==0);
lcd.print(x);
AP=Serial.parseInt();
}
line();
}

Digital Clock Using Tinkercad: Page 4


Step 4: Click on Start Simulation in Tinkercad and Set the Current Time and Date

1. Click on code option and then click on Serial Monitor option.


2. Now click on Start Simulation and set the current time and date, just by answering simple questions like
"Enter current hour:", "Enter current minute:", "Enter current second:", "Enter AM (0) or PM(1)", "Enter
current month:", "Enter current day:", and "Enter current year:".

Step 5: Catch Sight of Digital Clock Output on the LCD

Now the Digital Clock is ready, and you can watch the time and date on it.

Digital Clock Using Tinkercad: Page 5

You might also like