Introduction
Making a Digital Clock using Arduino with RTC Module is one of the most useful and practical electronics projects for beginners as well as intermediate makers. In this tutorial, we will build a 4-Digit 7-Segment Digital Clock using LEDs, Arduino Uno, and DS3231 RTC Module, which automatically keeps accurate time even after power failure.
Unlike simple Arduino clocks that lose time when power is removed, this project uses a real-time clock (RTC) to store and maintain time continuously. We will also learn how to manually construct a 4-digit common anode 7-segment display using 5mm LEDs, wire it correctly, upload the code, set time using switches, and finally make it fully standalone with a battery-backed RTC module.
This is a complete full tutorial including hardware construction, wiring, Arduino programming, and final enclosure assembly.
Components Required
Take all components before starting the project:
- 5mm LEDs × 116 pieces (any color of your choice)
- Arduino Uno × 1 (Arduino Nano can also be used)
- RTC Module – DS3231 × 1
- Push Button Switch × 2
- Toggle / Adjust Switch × 1
- 220Ω Resistor × 1
- Li-ion Battery (3.7V)
- TP4056 Li-ion Charger Module
- Custom Enclosure Box (6mm MDF Board)
- Connecting wires, soldering iron, solder wire
- Drill machine with 5mm drill bit
- Sand paper
Step-1: Preparing the Front Panel (7-Segment Layout)
- Take a 6mm MDF board and mark the layout for a 4-digit, 7-segment display.
- Drill 5mm holes for each LED exactly as per the segment shape.
- Each segment will contain 4 LEDs, so one digit will have 28 LEDs.
- Smooth the front panel by rubbing it with sand paper to remove rough edges.
This MDF panel will act as the front face of your digital clock.
Step-2: Inserting LEDs & Making Common Anode
- Insert LEDs one by one into the drilled holes.
- Make sure all anode legs remain on the outer side.
- Solder all 28 anodes together — this forms a Common Anode for that digit.
Now connect cathode legs segment-wise:
- All 4 LEDs of Segment A → connected together
- All 4 LEDs of Segment B → connected together
- Continue same for Segments C, D, E, F & G
👉 Now Digit-1 Common Anode 7-Segment Display is ready.
Step-3: Repeat for Remaining Digits
Repeat the same process for:
- Digit-2
- Digit-3
- Digit-4
Step-4: Dot LEDs (Clock Separator)
- Place 4 LEDs between Digit-2 and Digit-3 (center of panel).
- Connect all anodes together.
- Connect all cathodes together.
- Insert a 220Ω resistor in series with dot anode to balance brightness.
👉 These dot LEDs will blink every 1 second, giving a real digital clock effect.
Step-5: Making Common Segment Lines
Now we will create common segment lines so that the same segment of all digits can be controlled together using Arduino multiplexing.
- First, keep the common anode wires of all four digits separate. Each digit will have its own anode control wire, which will be used later to turn ON one digit at a time.
- Now start connecting the segment cathodes digit-wise in parallel. This means the same segment of all digits will share one common wire.
- Take a single wire and connect it to the cathode of Segment-A of Digit-1. From the same wire, continue the connection to:
- Segment-A of Digit-2
- Segment-A of Digit-3
- Segment-A of Digit-4
This wire will now act as the common Segment-A (Seg-A) line.
4. Similarly, take another wire and connect the cathode of Segment-B of all four digits together. This becomes the Seg-B common line.
5. Repeat the same process for the remaining segments:
- Segment-C → common Seg-C wire
- Segment-D → common Seg-D wire
- Segment-E → common Seg-E wire
- Segment-F → common Seg-F wire
- Segment-G → common Seg-G wire
After completing these connections, each segment (A to G) will have one common cathode wire shared across all four digits, while each digit will still have its own individual anode control.
At this stage, the display wiring structure is fully prepared and ready to be connected to the Arduino for multiplexed control.
Step-6: Arduino Pin Connections
Connect display wires to Arduino as below:
Segment Connections
- Segment A → D8
- Segment B → D7
- Segment C → D6
- Segment D → D5
- Segment E → D4
- Segment F → D3
- Segment G → D2
Dot LEDs
- Dot Anode → D9
- Dot Cathode → GND
Digit Control
- Digit-1 (Hour Tens) → D10
- Digit-2 (Hour Units) → D11
- Digit-3 (Minute Tens) → D12
- Digit-4 (Minute Units) → D13
Step-7: Installing Required Arduino Library (Without RTC)
- Connect Arduino Uno to laptop using USB cable.
- Open Arduino IDE.
- Go to Sketch → Include Library → Manage Libraries.
- Search and install TIME Library.
- Make sure your system is connected to the internet.
Step-8: Upload Clock Code (Without RTC)
- Download the provided 12-Hour Digital Clock code.
- Open Arduino IDE → File → Open → select code file.
- Go to Tools → Board → Arduino Uno.
- Select correct COM Port.
- Click Upload.
After upload:
- All digits glow except first digit initially.
- After 2 minutes, time starts increasing.
- This confirms the clock is working.
Step-9: Time Adjustment Switches
Switch Connections
- One side of all switches → Common
- Adjust Toggle Switch → A0
- Minute Push Button → A1
- Hour Push Button → A2
How to Set Time
- Turn Adjust switch ON
- Press Hour button to set hours
- Press Minute button to set minutes
- Release Adjust switch to start clock
If power is removed, time resets.
Step-10: Adding DS3231 RTC Module (Permanent Time)
RTC Connections
- GND → GND
- VCC → 5V
- SDA → A4
- SCL → A5
👉 Insert 3V coin cell into RTC module before uploading code.
Step-11: Installing RTC Libraries
Install following libraries:
- Wire
- RTCLib
Path:
Sketch → Include Library → Manage Libraries
Step-12: Upload RTC Code
- Open RTC clock code in Arduino IDE.
- Compile and upload.
- Time is automatically synced from laptop to RTC.
✔ Now time will NOT reset even after power cut.
✔ Manual adjustment also updates RTC memory.
Step-13: Final Assembly
- Fix all components inside 6mm MDF enclosure
- Mount front panel display
- Secure Arduino, RTC, TP4056, and battery
- Close the box neatly
Final Output & Usage
Your Arduino Digital Clock with RTC Module is now complete.
You can use it for:
- Study table
- Home decoration
- Shop display
- Engineering projects
- DIY electronics demonstrations
This project uses 12-Hour format, but it can easily be modified to 24-Hour format by editing the code.
Conclusion
This Arduino digital clock project using DS3231 RTC module demonstrates practical skills in LED display construction, Arduino multiplexing, and real-time clock integration. It is a reliable, accurate, and professional-grade DIY clock suitable for home use, learning, and engineering projects.
The code currently works in 12-hour format and can be easily modified for 24-hour format as required.

















0 Comments