Introduction: How to Make a Digital Clock at Home Using Arduino & RTC Module - Auto Time Set
In this tutorial, you will learn how to build a fully automatic Arduino Digital Clock using a Real Time Clock (RTC) module. Unlike basic clocks that reset after every power failure, the RTC module keeps accurate time and updates the Arduino automatically. We will also design and assemble a 4-digit Common Anode 7-Segment LED Display using individual LEDs, resistors, and wiring. This guide covers circuit connections, coding, and time synchronization with the RTC module. Whether you’re a beginner or electronics enthusiast, this project will help you understand how digital displays work and how to create a reliable, accurate, and customizable clock.
Step 1: All the Required Components
Before starting the project, collect all the components -
- LEDs – 116 pieces (for making the 4-digit Common Anode 7-Segment Display)
- Arduino Uno/Nano – 1 unit
- RTC Module – DS3231 (for accurate timekeeping with auto time update)
- Push-Button Switches – 2 units (for setting hours and minutes if required)
- Toggle/Adjust Switch – 1 unit (to activate manual time adjustment mode)
- Resistor – 220Ω (1 unit) 1/4 watt
- Li-ion Battery (3.7V) (for backup power or portable use)
- Li-ion Charger Module (for safely charging the battery)
- Enclosure – Custom 6mm MDF Box (to mount the display and electronics neatly)
Step 2: Prepare the MDF Enclosure and Build the First 7-Segment Digit
In this step, we will prepare the MDF front panel for the display and assemble one complete Common Anode 7-Segment Digit using LEDs.
1. Prepare the MDF Panel
- Take a 6mm MDF board that will be used as the front enclosure of your clock.
- Mark the positions for all 4 digits of the 7-segment display.
- Using a 5mm drill bit, make precise holes for the LEDs exactly as shown in the reference image.
- Ensure all holes are aligned properly so the digits look clean and symmetrical from the front.
2. Insert LEDs Into the Panel
- Insert 28 LEDs into the drilled holes for the first digit.
- Make sure the anode (positive leg) of all LEDs faces outward, as these will be soldered together to create a Common Anode.
3. Create the Common Anode
- Bend all the anode legs toward the outer side.
- Carefully solder all 28 anode legs together.
- This will make the entire digit share one common anode connection.
4. Connect the Cathodes Segment-Wise
Each 7-segment digit has 7 main segments (A–G).
For each segment:
- Connect the cathode legs of the LEDs belonging to Segment A together.
- (All 4 LEDs of Segment A → 1 cathode line)
- Do the same for Segment B, connecting all cathode legs of these 4 LEDs together.
- Repeat this process for all other segments:
- C, D, E, F, and G.
Once completed, your first 7-segment Common Anode digit is fully ready.
Step 3: Build the Remaining Digits and Connect the Dot LEDs
After completing the first digit, follow the same process to build all four digits of the display. Then, we will prepare the dot (colon) LED.
1. Repeat the Same Steps for Digit 2, 3, and 4
- Drill 5mm holes on the MDF board for all remaining three digits.
- Insert 28 LEDs into each digit.
- Keep all anodes facing outward and solder them together to make a Common Anode for each digit.
- Connect the cathodes of each segment (A–G) together just like Digit 1.
Now you will have four complete Common Anode 7-segment digits.
2. Connect the Single Dot LED (Blinking Every 1 Second)
- Take 4 LEDs for the dot indicator.
- Connect all anodes of these 4 dot LEDs together in parallel.
- Connect all cathodes of these 4 dot LEDs together in parallel.
Step 4: Connect Common Anode Wires and Create Segment-Wise Common Cathode Lines
Now that all four digits and the single dot LED are ready, it’s time to wire the display so it can be controlled by the Arduino.
1. Connect the Common Anodes of All 4 Digits
- Each 7-segment digit has one Common Anode.
- Take 4 separate wires and connect each one to the Common Anode of each digit individually.
- Wire 1 → Digit 1 Common Anode
- Wire 2 → Digit 2 Common Anode
- Wire 3 → Digit 3 Common Anode
- Wire 4 → Digit 4 Common Anode
These 4 wires will later be used to enable each digit one at a time.
2. Create Segment-Wise Common Cathode Connections
Now we will create shared cathode lines for each segment (A to G) across all four digits.
Segment A
- Take one wire and solder it to the Segment A cathode of Digit 1.
- Extend the same wire to Segment A of Digit 2.
- Again connect the same wire to Segment A of Digit 3.
- Finally connect it to Segment A of Digit 4.
- This wire becomes the Common Cathode line for Segment A.
Segment B to Segment G
- Repeat the same process for the remaining segments:
- Segment B → Wire to all digits
- Segment C → Wire to all digits
- Segment D → Wire to all digits
- Segment E → Wire to all digits
- Segment F → Wire to all digits
- Segment G → Wire to all digits
You will now have 7 segment common cathode wires (one for each segment).
3. Connect the Dot LED Wires
- Take two wires from the Dot LED:
- One for the Anode
- One for the Cathode
- These wires will be used to blink the dot at 1-second intervals.
NOTE: Use hot glue to stick all these components in the board.
Step 5: Connect All Digit, Segment & Dot LED Wires to the Arduino
Now it’s time to connect all the wires from your 4-digit 7-segment display to the Arduino Uno according to the circuit diagram. Make sure to follow these pin assignments exactly for the code to work properly.
1. Connect All Segment Wires to Arduino Pins
These wires control which segments will turn ON across all digits:
- Segment A → D8
- Segment B → D7
- Segment C → D6
- Segment D → D5
- Segment E → D4
- Segment F → D3
- Segment G → D2
2. Connect the Dot LED
You have one Dot LED formed from 4 LEDs in parallel:
- Dot Anode → D9
- Dot Cathode → GND
3. Connect All Digit Common Anodes
- Digit 1 (Hour Tens) → D10
- Digit 2 (Hour Units) → D11
- Digit 3 (Minute Tens) → D12
- Digit 4 (Minute Units) → D13
These pins are responsible for multiplexing each digit one-by-one at high speed so the display appears steady.
Step 6: Upload the Code to the Arduino
Now that all the wiring is complete, it’s time to upload the Arduino code. Follow these steps carefully to ensure everything works properly.
DOWNLOAD CODE - https://drive.google.com/file/d/1466L...
1. Connect Arduino to Your Laptop/PC
- Use a USB cable to connect your Arduino Uno to your computer.
- Make sure the cable is working and the Arduino power LED turns ON.
2. Open Arduino IDE
- Launch the Arduino IDE software on your laptop/PC.
- Make sure your system is connected to the internet, because we need to install a library.
3. Install the TIME Library
To run the clock code, you must install the TIME library.
- Go to Sketch → Include Library → Manage Libraries
- The Library Manager window will open.
- In the search bar, type “Time”
- Install the library named Time or TimeLib (depending on the version).
Once installed:
- Go to Sketch → Include Library,
- Scroll down and check if the Time library is visible.
- If yes → The library is successfully installed.
4. Open the Digital Clock Code
- Go to File → Open
- Select the 12-Hour Format Digital Clock Code that you want to upload.
- The code will open inside the Arduino IDE.
5. Compile the Code
- Click the Compile (Verify) button.
- Wait until the progress bar completes.
- If no errors appear, your code is ready to upload.
6. Select the Correct Board & Port
Before uploading, choose the correct hardware settings:
- Go to Tools → Board → Arduino Uno
- You may also use Arduino Nano, but select the correct chipset if using Nano.
- Go to Tools → Port
- Select the COM port on which your Arduino Uno is connected.
- Other settings can remain the same as shown in the above picture.
7. Upload the Code
- Now click the Upload button (right arrow icon).
- Wait until the IDE shows “Upload completed.”
8. Check the Display
After uploading:
- You will notice 6 segments in all 3 digits glowing except the first digit.
- After about 2 minutes, you will see the time begin to increase.
- This confirms your clock is working perfectly with the code.
Step 7: Fix Dot LED Brightness Using a 220Ω Resistor
After uploading the code and powering the display, you may notice that the Dot LED is glowing with very high brightness. This happens because the dot LEDs are directly connected without any current-limiting resistor.
1. Add a 220Ω Resistor to the Dot LED
- Take a 220Ω resistor 1/4 watt
- Connect it in series with the Dot LED Anode wire
- (Dot Anode → 220Ω Resistor → Arduino D9)
This resistor limits the current flowing to the dot LEDs and reduces the brightness to match the segments.
Step 8: Add Switches to Adjust and Set the Time
To manually set or adjust the time on your digital clock, you need to add two Push-Button switches (Hour & Minute) and one Toggle/Adjust Switch. These switches allow you to enter time-set mode and update the hour and minute values directly from the Arduino.
1. Connect the Switches as Shown in the Circuit Diagram
Common Connection
- Take one side of all three switches and connect them together to GND.
Signal Side Connections
Connect the other side of each switch to Arduino inputs:
- Adjust Toggle Switch → A0
- Minute Push Button → A1
- Hour Push Button → A2
These pins will be used to detect switch presses inside the Arduino code.
2. How to Set the Time
Step 1: Activate Time-Set Mode
- Press the Adjust Toggle Switch (A0)
- This will put the clock into Time Adjustment Mode.
Step 2: Set the Hour
- Press the Hour Push Button (connected to A2).
- Each press will increase the hour value by 1.
Step 3: Set the Minutes
- Press the Minute Push Button (connected to A1).
- Each press will increase the minute value by 1.
Step 4: Exit Time-Set Mode
- Release the Adjust Toggle Switch.
- The clock will return to normal running mode.
3. Observe the Clock Running
After you exit time-set mode:
- The display will resume counting,
- You will see the time increasing minute by minute,
- And the dot LED will keep blinking every 1 second.
✔ You Can Use This Clock Now!
Your clock is fully operational—but it has one limitation:
If the power turns OFF, the time resets, and you must set it again.
To solve this issue, continue to the next step, where we add an RTC Module (DS3231) to keep the time running even without power.
Step 9: Connect the DS3231 RTC Module to Arduino
To keep the clock running even when the power is OFF, we will now add the DS3231 Real-Time Clock (RTC) Module. This module has an internal battery that maintains accurate time independently.
1. Connect the RTC Module to the Arduino
Make the following simple connections:
- GND → GND
- VCC → 5V
- SDA → A4
- SCL → A5
These two pins (SDA & SCL) are used for I²C communication between Arduino and the RTC.
2. Insert the RTC Backup Battery
Before uploading the code again:
- Ensure the 3V coin cell (CR2032) is properly inserted in the RTC module.
- This battery keeps the time running even when the Arduino is turned off.
Step 10: Upload the RTC-Based Code to Arduino
You can run this project on Arduino Uno or Arduino Nano. Both work perfectly with the DS3231 RTC module.
Now let’s upload the updated code that uses the RTC.
DOWNLOAD CODE WITH RTC MODULE -https://drive.google.com/file/d/1466L...
1. Open the RTC Clock Code
- Download the provided RTC version of the clock code.
- Open Arduino IDE.
- Go to File → Open and select the downloaded code.
2. Install Required Libraries
This code requires two additional libraries:
- Wire
- RTCLib
To install them:
- Go to Sketch → Include Library → Manage Libraries
- Search for “Wire” → Install
- Search for “RTCLib” → Install (by Adafruit or compatible)
Make sure your PC/laptop is connected to the internet.
3. Upload the Code
- Select the correct board:
- Tools → Board → Arduino Uno / Arduino Nano
- Select the correct port:
- Tools → Port → (choose COM port)
- Click Upload.
After a few seconds, the code will be uploaded successfully.
4. Check the Display
- Now you will see the correct time on the 7-segment display.
- The RTC automatically takes the current time from your laptop/PC when the code is uploaded.
5. Manual Time Adjustment (Optional)
If you want to manually change the time:
- Press the Adjust Toggle Switch
- Use Hour and Minute Push buttons
- The updated time will also be saved into the RTC.
6. Power Loss Protection
Now your clock is fully reliable:
- Even if Arduino power is turned OFF,
- The RTC module keeps running the time using the backup 3V battery.
- When the power comes back, the clock will instantly show correct time again.
Step 11: Assemble Everything Inside the MDF Enclosure
Now that all wiring and code uploading is complete, it’s time to place your clock into the MDF enclosure.
1. Fix the Display, Arduino & RTC Module
- Place the Display,Arduino Uno/Nano, DS3231 RTC Module, and switches inside the box.
- Keep wires arranged properly so the box closes easily.
3. Install the Switches
- Mount the Hour, Minute, and Adjust switches on the top side of the box for easy access.
4. Power Supply
You may use:
- USB cable
- 5V wall adapter
- OR a 3.7V Li-ion battery + charger module (if making it portable)
5. Close the Enclosure
- Finally, close the MDF box using screws or glue.
- Your professional-looking digital clock is now ready to use!
Step 12: Applications of This Digital Clock
✔ 1. Home or Office Digital Clock
Use it as a stylish handmade clock for your bedroom, study table, office table, or living room.
✔ 2. DIY Electronics Project / Engineering Project
- B.Tech/B.E Projects
- Diploma Engineering
- School Exhibition
- Hobby Electronics
✔ 3. Workshop or Lab Timer
Place it in your electronics lab or workshop as a reliable RTC-based timing device.
✔ 4. Teaching & Learning Tool
Ideal for teaching:
- Arduino programming
- RTC module usage
- Multiplexing
- 7-segment displays
- DIY circuit design
✔ 5. Decorative Desk Clock
Customize the MDF enclosure with paint or vinyl to make it a modern desk showpiece.
✔ 6. Smart Home Add-On
Can be integrated with:
- Sensors
- Alarm system
- Temperature display
- IoT modules (ESP8266/ESP32)
Step 13: Conclusion
This DIY digital clock project is a perfect blend of practical utility and hands-on learning. From wiring the 7-segment display to integrating the DS3231 RTC Module, you not only built a functional clock but also understood how real-time systems work. Once placed inside a neat MDF enclosure, it becomes a reliable, stylish, and long-lasting desk clock.
With the RTC module added, the clock now maintains accurate time even after power loss—making it far more dependable than the earlier version. This project also builds a strong foundation for future upgrades like adding alarms, temperature display, Bluetooth control, or even IoT-based features.
Overall, this was not just a clock—you created a complete electronics project that enhances your skills and inspires your next innovations!





