Simplest Arduino Clock With 7-digit segment display

From time to time, I’m also working on less “web” related project. This time, a wanted to play a bit with Arduino platform. The task was pretty simple – to build a clock. Yes – these days, we don’t have enough time measuring devices like mobiles, microwaves, computers – I wanted to build another one.

It was my first Arduino project so the task wasn’t  as easy as I expected. In the theory, we need only pass time & data from RTC to 7-Segment Display. Simple isn’t it? I found plenty of tutorials, had so many small issues like – digits wasn’t displayed correctly (mixed cables). I could only display one digit at the time in given position or – same digits everywhere (multiplexing). I couldn’t find shift register in my stock, so wanted to use whatever I already had.

I already was a proud owner of the whole set, which was:

  1. Arduino UNO R3,
  2. DS1307 Real Time Clock,
  3. 7-Segment Display,
  4. bunch of resistors, cables, and plenty of free time



Let’s cook!


SevSeg setup

From file:

The first argument (boolean) tells whether the display is common cathode (0) or common anode (1).
The next four arguments (bytes) tell the library which arduino pins are connected to the digit pins of the seven segment display. Put them in order from left to right.
The next eight arguments (bytes) tell the library which arduino pins are connected to the segment pins of the seven segment display. Put them in order a to g then the dp.

That was the hardest part of my whole build. Setting up SevSeg to work with my wiring.

sevseg.Begin(0, 4, 3, 2, 1, 12, 11, 10, 9, 8, 7, 6, 5);

Mine was pretty simple. I had a version with common cathode – the first digit is 0, then – pins connecting t a cathode (digit handling) and then segments displays – in my case digital outputs in androino 6-12 (A to G) Number 5 points to dot digit.

#include "SevSeg.h"
#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>
//Create an instance of the object.
SevSeg sevseg;
void setup() {
//I am using a common anode display, with the digit pins connected
sevseg.Begin(0, 4, 3, 2, 1, 12, 11, 10 , 9, 8, 7, 6,5);

//Set the desired brightness (0 to 100);
void loop() {
tmElements_t tm;
int time;
int dot;
if (
time = tm.Hour * 100;
time += tm.Minute;
if ((tm.Second % 2) == 0)
dot = 4;
dot = 2;
//Produce an output on the display
sevseg.NewNum(time, dot);

7 thoughts to “Simplest Arduino Clock With 7-digit segment display”

  1. sketch_jul01a:39: error: ‘class SevSeg’ has no member named ‘PrintOutput’
    sketch_jul01a:40: error: ‘class SevSeg’ has no member named ‘NewNum’

  2. Hi !
    Like you I’ve done this kind of clock, it works great. But don’t you have the problem of the leading 0 not displaying ? Its weird to have a clock telling 1 instead of 0001. If you have any idea, I’ll be glad to hear it 🙂
    Great post by the way ! 🙂

  3. Pls I need help,I want to build a 10 numerical digital sign displaying,to be able to display numbers from 1 to 10 with 10 switches,any switch from 1 to 10 that is energized will indicate the number, I want to build it in a hospital ward,a patient in room one can easily press the number 1 button in case there is an emergency,so also other buttons,they will display the button number that is press in the numerical digital sign display board

    1. First think which comes to my mind is to how to solve 10 buttons connection. Maybe numeric keyboard will be easier?
      Disolay itself isn’t a problem – just need to find something which portable via serial

    1. Sorry I don’t have one. Basicially you hoop up all pins from segment display to Arduino, and then using sevseg.Begin(0, 4, 3, 2, 1, 12, 11, 10, 9, 8, 7, 6, 5); define order of the pins

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.