Sunday, August 5, 2012

Review: 4-digit 7-segment LED and RTC from Adafruit

In this review, I thought I would combine Adafruit's 0.56" 7-segment LED backpack and display and their DS1307 RTC (Real Time Clock) board. The obvious choice for such a combination is to make a simple clock!

Note that my pictures make the display look a little washed out. It wasn't, it was very bright. This is juts an effect of my photography lighting setup being even brighter.

Both modules are I2C and therefore just require two data pins along with GND and 5V. So, for anyone who has done their own multi-digit 7-segment LED multiplexing wiring up the breadboard becomes beautifully simple.

0.56" 7-Segment Backpack and Display

This comes as a kit of parts that need to be soldered together. Well actually just the PCB, header pins and the LED display itself. The surface mount chip is already soldered for you. 
Beginners will have no trouble with this, and Adafruit provide a very detailed construction guide.

DS1307 Real Time Clock breakout board kit

The RTC module is also supplied in kit form and would also suit someone new to soldering. Once again, the instructions are excellent. Showing you the right order in which to solder the components in a step-by-step manner with clear photographs as illustrations.

I got an extra resistor, but then I got more pin headers than I needed on both kits, so I think maybe its the Adafruit approach to err on the side of caution. Once assembled the Lithium battery (which should last years) can be inserted so that the module remembers the time.

Making a Digital Clock

Making the digital clock was delightfully simple, and basically merges together bits from the example scripts for the libraries for each module.

The Adafruit library for the display is nice, very easy to use. Their installation guide explains where to get it from github, along with a supporting library that it requires. 

The RTC module uses the Jee Lab's RTClib.

As normal with libraries, unzip the folders into your Arduino 'libraries' directory and then restart the Arduino IDE for it to pick them up. If you get an error message, as Arduino starts, about the libraries having invalid names, you missed the step of renaming the Adafruit libraries after unzipping them. Just rename the folders to remove the 'funny' characters and call them 'AdafruitLEDBackpack' and 'AdafruitGFXLibrary'.

Wire up your breadboard like this:

Coming from the Arduino, the leads are:
Red - 5V (Vcc)
Black - GND
Orange - A4 (SDA - data)
Yellow - A5 (SCL - clock)

These all just go to the pins with the same names on the two modules!

Paste the following sketch into a new Arduino window and upload it to your board. It will set the RTC to the time at which the sketch was compiled and uploaded. So, if your computer picks up its time from the Internet, that will be pretty accurate.
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "RTClib.h"

Adafruit_7segment disp = Adafruit_7segment();

void setup() 
  if (! RTC.isrunning()) 
    RTC.adjust(DateTime(__DATE__, __TIME__));

void loop() 

int getDecimalTime()
  DateTime now =;
  int decimalTime = now.hour() * 100 + now.minute();
  return decimalTime;

These modules make life easy and free up Arduino pins for other uses. 

Great supporting documentation telling you all you need to know to get you started and more. Two very useful modules at not a bad price. 

Never again, will I be messing around multiplexing a load of LEDs with transistors for  the common anode and having the Arduino run off its feet refreshing! This is much easier!

[disclosure: These models were provided by Adafruit to me F.O.C]

About the Author
These are my books. Click on the image below to find out more about them.



Sparr said...

I suspect you could save some power by putting the arduino to sleep for the 500ms delays instead of leaving it running.

Arduino lover said...

if you like everything related to micro-controllers visit my blog:

All about Embedded Systems

David willson said...

Nice blog thanks for sharing. led display lights