0.56″ 7-Segment Backpack (Part 1)

As far as the development of interactive applications is concerned there always is a need for displaying information in a human readable format.. Let’s start with a quick and dirty review of the available options with Arduino.

Display Usage Pros Cons
One monchrome LED* use on/of state, use blink rate, use morse code ** Cheap Limited information
One RGB LED Same as before except more combinations Pretty cheap Little more wiring
LCD display (16×2) Display 2 lines containing 16 alpha numerical characters Human readable messages, affordable Requirements for wiring and programming***
OLED display (16×2) Display 2 lines containing 16 alpha numerical characters Human readable messages, high contrast, lower power Pricey. Requirements for wiring and programming***
GLCD Display graphics as well as  alpha numerical characters (typically 128 x 64 pixels) Plot and print Costly
Grphic OLED Display graphics as well as  alpha numerical characters (typically 128 x 64 pixels) Plot and print, color version available Up to expensive

* e.g. digital pin 13 LED !

** If you are from the navy

*** Consider buying a backpack which allows serial communication (e.g. I2C) and save pins

And then come the LED displays. I say “then” and not “finally” because LED displays were among the very first types of displays used on electronics appliances, including the now looking ugly and dated alarm-clocks. LED display come in various formats, sizes and price. They can be 7 segment digits for numerical data or 14/16 segments digits for alpha-numerical data.

seven_segments

Also, take care about the wiring as LED digits can be wired with common cathode or common anode.

common_cathodecommon_anode

Driving a LED digits requires quite many ports: for a 7 segments digit require 7 data lines for each segment plus an extra one for the decimal point (marked “dp”, if applicable) and one for the common points (cathode or anode as explained before). One additional data line is necessary for each additional digit. If we take the example of the module which combines 4 digits a total of (7 + 1) + (4 * 1) lines are necessary that’s a lot compared to the available lines from an Arduino board for example.

SKU020620-1SKU020620-2

This problem can be easily solved thanks to dedicated chips which enable the driving of the digits through serial commands (SPI and/or I2C). Adafruit proposes such nice small and affordable solutions under the form or kits:

Adafruit 0.56″ 4-Digit 7-Segment Display w/I2C Backpack – White PID: 1002

1002-00

Quad Alphanumeric Display – White 0.54″ Digits w/ I2C Backpack PID: 2157

2157-03

These displays exist in various colors (Red, Green, Yellow, Blue, Orange)

Here is a simple example of use of the numerical display used for displaying the temperature reading from a TMP04 sensor with the PlainTMP library:

temp_reader

Here is the code to be used in order to achieve this type of display

/*************************************************** 
  This is a library for our I2C LED Backpacks

  Designed specifically to work with the Adafruit LED 7-Segment backpacks 
  ----> http://www.adafruit.com/products/881
  ----> http://www.adafruit.com/products/880
  ----> http://www.adafruit.com/products/879
  ----> http://www.adafruit.com/products/878

  These displays use I2C to communicate, 2 pins are required to 
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
  
  Modified by Didier Longueville for Arduinoos
  GLP v2 license
 ****************************************************/

#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
/* include libraries */
#include <PlainTMP0x.h> /* TMP0x sensors library */

Adafruit_7segment matrix = Adafruit_7segment();
PlainTMP0x TMP; /* Create an instance of the TMP object */

/* Create objects */
/* Change parameters according to hardware configuration */
const uint8_t _pin = PIND7;
volatile uint8_t *_port = &PORTD;
const uint32_t _interval = 5000;
int32_t _now, _lastTime;

void setup() 
{
	/* Initialize display */
	matrix.begin(0x70);
	/* Adjust brightness from 1 to 15 */
	matrix.setBrightness(0x01);
	/* Initialize display prior to first temperature reading */
	matrix.print(99999);
	matrix.writeDisplay();
}

void loop() 
{
	do {
		_now = millis();
	} while ((_now - _lastTime) < _interval);
	_lastTime = _now;
	/* run measurement */
	float temperature = TMP.Temperature(TMP_MOD_TMP04, _port, _pin, TMP_UNI_CELSIUS, 16);
	/* Display temperature */
	matrix.print(temperature);
	matrix.writeDisplay();

}

 

Good readings:

LEDs Are Still Popular (and Improving) after All These Years, by MAXIM DALLAS [Here]

Leave a Reply

You must be logged in to post a comment.