In a previous project I used a 4 digit 7 segment display.
I was short of pins so I used 2 A6276 16-Bit Serial Input, Constant-Current
Latched LED Drivers.
This only used 3 digital pins.
I wrote a library for this display:
In my current project for the 4 digit 7 segment display I used charlieplexing.
Wikipedia, the free encyclopedia has a description.
This uses 8 digital pins and no extra components:
The program is interupt driven. TIMER2(Arduino PWM 3 and 11)
generates interupts every 720 usec.
The program uses less than 1% of CPU time.
It uses 30 bytes of RAM and 900 bytes of flash.
The CMOS digital pins provide a peak drive current of 45 mA.
Each segment of the 28 is driven once every 20 msec.
This gives 1.6 mA average current per segment.
If the display is not bright enough use high intensity displays.
The code is all in a class which has 4 functions:
This sets up Timer2 and starts interupts.
This stops interupts and puts the digital pins into tristate.
This displays numbers in the range 0000 to 9999.
If it is not in the range “EEEE” will be displayed.
Picture is 32 bits which map to each segment.
x is dont care. A 1 lights the segment a 0 turns it off.
7 segment display:
f | | b
e | | c
The library has 2 examples. To demonstrate counting:
//simple program to demonstrate counting
unsigned int d = 0;
}//end of setup
}//end of loop
Down load fourdigitLEDC from: