Happy Arduino Day! Use the code ARDUINODAY on checkout and get 10% off your order on all items in stock!

0.56" 7-Segment Backpack

Author Gravatar Image LADY ADA
This version of the LED backpack is designed for these big bright 7-segment displays. These 7-segment displays normally require 13 pins (5 'characters' and 8 total segments each) This backpack solves the annoyance of using 13 pins or a bunch of chips by having an I2C constant-current matrix controller sit neatly on the back of the PCB. The controller chip takes care of everything, drawing all the LEDs in the background. All you have to do is write data to it using the 2-pin I2C interface. There are three address select pins so you can select one of 8 addresses to control up to 8 of these on a single 2-pin I2C bus (as well as whatever other I2C chips or sensors you like). The driver chip can 'dim' the entire display from 1/16 brightness up to full brightness in 1/16th steps. It cannot dim individual LEDs, only the entire display at once.
When you buy a pack from Adafruit, it comes with the fully tested and assembled backpack as well as a 7-segment display in one of the colors we provide (say, red, yellow, blue or green). You'll need to solder the matrix onto the backpack but it's an easy task.
Remove the parts from packaging and place the LED matrix OVER the silkscreen side. DO NOT PUT THE DISPLAY ON UPSIDE DOWN OR IT WONT WORK!! Check the image below to make sure the 'decimal point' dots are on the bottom, matching the silkscreen.
Turn the backpack over so it is sitting flat on the matrix.
Solder all 14 pins.
Clip the long pins.
Now you're ready to wire it up to a microcontroller. We'll assume you want to use a 4pin header. You can also of course solder wires directly. Place a 4-pin piece of header with the LONG pins down into the breadboard.
Place the soldered backpack on top of the header and Solder 'em!
That's it! now you're ready to run the firmware!

Seven-Segment Backpack Firmware

We wrote a basic library to help you work with the 7-segment backpack. The library is written for the Arduino and will work with any Arduino as it just uses the I2C pins. The code is very portable and can be easily adapted to any I2C-capable micro.

Wiring to the matrix is really easy

  • Connect CLK to the I2C clock - on Arduino UNO thats Analog #5, on the Leonardo it's Digital #3, on the Mega it's digital #21
  • Connect DAT to the I2C data - on Arduino UNO thats Analog #4, on the Leonardo it's Digital #2, on the Mega it's digital #20
  • Connect GND to common ground
  • Connect VCC+ to power - 5V is best but 3V also seems to work for 3V microcontrollers.

Next, download the Adafruit LED Backpack library from github . To download click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_LEDBackpack. Check that the Adafruit_LEDBackpack folder contains Adafruit_LEDBackpack.cpp and Adafruit_LEDBackpack.h Place the Adafruit_LEDBackpack library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if it's your first library. You'll also need to download the Adafruit GFX library - rename it Adafruit_GFX and install it as the LED backpack library. It's not actually used for the 7-segment, it's only for the matrix backpacks but it's still required. Restart the IDE.

Once you've restarted you should be able to select the File?Examples?Adafruit_LEDBackpack?sevenseg example sketch. Upload it to your Arduino as usual. You should see a basic test program that goes through a bunch of different routines.



Once you're happy that the matrix works, you can write your own sketches.

There's a few ways you can draw to the display. The easiest is to just call print - just like you do with Serial

  • print(variable,HEX) - this will print a hexidecimal number, from 0000 up to FFFF
  • print(variable,DEC) or print(variable) - this will print a decimal integer, from 0000 up to 9999

If you need more control, you can call writeDigitNum(location, number) - this will write the number (0-9) to a single location. Location #0 is all the way to the left, location #2 is the colon dots so you probably want to skip it, location #4 is all the way to the right. If you want a decimal point, call writeDigitNum(location, number, true) which will paint the decimal point. To draw the colon, usedrawColon(true or false)

If you wnat even more control, you can call writeDigitRaw(location,bitmask) to draw a raw 8-bit mask (as stored in a uint8_t) to that location.

All the drawing routines only change the display memory kept by the Arduino. Don't forget to call writeDisplay() after drawing to 'save' the memory out to the matrix via I2C.

There are also a few small routines that are special to the backpack:

  • setBrightness(brightness)- will let you change the overall brightness of the entire display. 0 is least bright, 15 is brightest and is what is initialized by the display when you start
  • blinkRate(rate) - You can blink the entire display. 0 is no blinking. 1, 2 or 3 is for display blinking.
Last updated on 2015-03-29 at 11.20.06 PM Published on 2012-07-29 at 03.58.38 PM