This is a general purpose 4 digit 7 segment LED display.
It uses two 16 bit serial input constant-current LED
drivers with four 7 segment displays.
It uses 3 digital pins from the arduino.
The code is all in a class which has 4 functions:
SEVEN.displayI(int number)
This displays numbers in the range -999 to 9999.
The number is left justified. If it is not in
the range “EEEE” will be displayed.
SEVEN.displayF(float number)
This displays numbers in the range -99.9 to 999.9.
One decimal point is displayed.
The number is left justified. If it is not in
the range “EEEE” will be displayed.
SEVEN.displayP(long picture)
Picture is 32 bits which map to each segment.
SEVEN.displayA(long origional,unsigned char addition)
This is designed to be used with displayI or displayF.
It adds the right hand character to the display.
An example program showing use of the class
// simple program to show uses
#include <SEVEN.h>
void setup() { }
void loop()
{
SEVEN.displayI(789); //displays "789_"
delay(1000);
SEVEN.displayF(-1.234); //displays "-1.2_"
delay(1000);
SEVEN.displayP(0x1e5f4138); //displays "FAIL"
delay(1000);
SEVEN.displayA(SEVEN.displayF(25.7),0x3a); //displays "25.7C"
delay(1000);
}
The connections and the 7 segment display I use give
the following bit connection diagram.
D1
| |
| |
D3 | | D0
| |
| |
D2
| |
| |
D4 | | D6
| |
| |
__
D5 |dp| D7
To display a “3” the bits are:
D7 D6 D5 D4 / D3 D2 D1 D0
0 1 1 0 / 0 1 1 1 = 0x67
The reason for the functions in the class is that I am
using them all for my Arduino indoor weather station:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1265087241
I use the PC to display the weather data and the arduino is
just a box with two LEDs. Looking through forum I found
a multiple LED display using three digital pins.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264989981/0#8
I decided to use an extra pin and make the arduino
more interesting by showing the current data using 4 LEDs.
The arduino has a good tutorial for this type of circuit.
The 74HC595 is not designed to drive LEDs. It will work within
specification if you limit the current through each segment to
(75/8) 9.3 mA. The 220 ohm limiters in this circuit give a
maximun load current of 109 mA for 2v LEDs.
This exceeds the spec of 75mA.
With all segments on the poor little thing will be stretched.
If you put a 220 in the common leg only you get different
intensitys for the segment patterns.
The artical also suggests the STP16C596 with built-in constant
current sources. I chose to go with a A6276:
I set the current limit to 10mA per segment. This gives a maximun
of 320mA which can be handled by the USB.
The 7 segment display I used is a HDSP-521E:
The programs and other files are at the site given below.
Download fourdigitLED.zip