Jump to content
Electronics-Lab.com Community

Digital Wall Clock on PCB using AVR Microcontroller Atmega16 and DS3231 RTC

Recommended Posts

Every digital clock has a crystal inside it to keep track of time. This crystal is not only present in the clock but also present in all computing real-time systems. This crystal generates clock pulses, which is needed for timing calculations. Although there are some other ways to get clock pulses for higher accuracy and frequency, but the most preferred way is to use crystal to keep track of time. Here we will DS3231 RTC IC to build an Atmega16 based Digital Wall Clock. DS3231 RTC has a highly accurate crystal inside it, so no external Crystal oscillator is needed.

In this Digital Clock Project, ten common anode 7-segment displays of 0.8-inch are used to display time and date. Here seven segment displays are used to show hour, minute, date, month and year. Our PCB design also has options to display seconds and temperature, which can be displayed by adding more display units.  

Circuit Diagram and Explanation 

There are two parts of this Digital Wall Clock Circuit, one is display part which has 5 pairs of 7-segments on five different PCB boards and another is controlled Unit part which is responsible for fetching time from RTC chip and send that data and time to 7-segment display. As we have used 10 seven segment displays so we cannot connect each display with a separate IO port. So here multiplexing technique is used to connect multiple seven segments using fewer pins of microcontroller.

Seven Segment Display

LED pins a,b,c,d,e,f,g,h of seven segment display is connected to PORTB of atmega16 parallel. Here we have used 10 seven segment displays so we need 10 control pins which are connected at PORTD, PORTA and PORTC.

RTC DS3231 having an internal crystal is connected to PORTC’s SDA and SCL pin because this chip works on I2C communication. Interfacing method of this chip is the same as DS1307. We have used DS1307 with Arduino, Raspberry Pi and 8051 MCU.  Same code can be used for both DS3231 and DS1307.


For one display board, two seven segment displays and 2 LED are used. So here we have five different display boards to display Time in Hours and minute (HH-MM), and date in DD-MM-YY.

Components Symbol for Digital Wall Clock using AVR Microcontroller Atmega16 and DS3231 RTC

Components for Digital Wall Clock using AVR Microcontroller Atmega16 and DS3231 RTC

PCB Design and fabrication for the Digital Clock 

For this Atmega16 based wall clock project, we have designed two PCBs. One is for Control unit which is used to control all the operations of the project and second part is for displaying the time and date on seven segment displays. Display part contains five pairs of 0.8 inches seven segment display. So by assembling 5 pieces we have the complete Digital Clock. To multiplex 7-segment displays, Data line of the 5 PCBs will be connected to the same port of control unit and control line is connected different pin of the control unit.

Below are the top and bottom views of PCB layouts of one Display board which consists two seven segment displays:

PCB Design of Digital Unit

Below are the top and bottom views of Control Unit PCBs

PCB Design of Control Unit for Digital Clock

Ordering the PCB using PCBGoGo

There are many PCB fabrication services are available online, but as I used PCBGoGo previously in one of my other projects, I found it cheap and hassle-free as compared to other vendors.

Here are the steps to order PCB from PCBGoGo:

Step 1:  Get into www.pcbgogo.com, sign up if this is your first time. Then, in the PCB Prototype tab enter the dimensions of your PCB, the number of layers and the number of PCB you require.

Ordering the PCB using PCBGoGo

Step 2: Proceed by clicking on the Quote Now button. You will be taken to a page where to set few additional parameters if required like the material used track spacing etc. But mostly the default values will work fine. The only thing that we have to consider here is the price and time. As you can see the Build Time is only 2-3 days and it just costs only $5 for our PSB. You can then select a preferred shipping method based on your requirement.

Enter Dimension for Ordering PCB using PCBGoG

Step 3: The final step is to upload the Gerber file and proceed with the payment. To make sure the process is smooth PCBGOGO verifies if your Gerber file is valid before proceeding with the payment. This way you can sure that your PCB is fabrication friendly and will reach you as committed.

Now PCBGoGo will take some time around 10 min to 1 Hour to review your Gerber file. After completion of the review, you can proceed with the payment.

Add Gerber File of Ordering PCB using PCBGoGo

Review Gerber File of Ordering PCB using PCBGoGo

Assembling the PCB

After the board was ordered, it reached me after some days though courier in a neatly labeled well packed box and like always the quality of the PCB was awesome. I am sharing few pictures of the boards below for you to judge.

PCB for Digital Wall Clock

Top and Bottom View of Digital Wall Clock PCB

I turned on my soldering rod and started assembling the Board. Since the Footprints, pads, vias and silkscreen are perfectly of the right shape and size I had no problem assembling the board. The board was ready in just 10 minutes from the time of unpacking the box.

Few pictures of the board after soldering are shown below.

Circuit Hardware for Digital Wall Clock using AVR Microcontroller Atmega16 and DS3231 RTC

Testing the Digital Clock 

Complete code is given at the end of this tutorial, just connect the PCBs as shown in the circuit diagram and upload the code into Atmega16. And you will see time and date appearing on the ten Seven segments displays.

Testing Digital Wall Clock using AVR Microcontroller Atmega16 and DS3231 RTC




Link to comment
Share on other sites

Hi KrisDong,

This is a simple time-of-day digital clock, a good starting point for learning the basics on microcontrollers. It uses the 18-pin PIC16F84A, a seven-segment LED clock display and three input switches. I have almost preserved the same hardware and ordered an appropriate printed circuit board from www.greatpcb.com for making the project simple. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...