4-Digit 7-segment LED Display Arduino Demo


The 4-Digit 7-Segment Display is a self-contained module containing four 7-segment LED numeric displays.  This demo, supporting the 2013 National microMedic Contest kits, uses the display with the Board of Education Shield for Arduino. 

Each segment in the display is multiplexed, meaning it shares the same anode (positive) connection points, labeled a through g. This reduces the wiring required  when developing projects that need multiple digit displays.

Each of the four digits in the module use their own common cathode (negative) connection point. This allows each digit to be turned on or off independently.





The LED segments of this display require a current-limiting resistor when powered from a 5 V logic pin. The following figure demonstrates the basic concept behind using a current-limiting resistor. The value of the resistor is typically between 330 and 560 ohms; the higher the value, the more the current that is limited, and the less bright the LED segments.






To connect the 4-digit 7-segment display to the Arduino Shield, attach the three leads of the device as shown in the figure. Note the use of additional components not included in the microMedic kit.

  • Resistors R1 through R7 limit current to each of the segments of the display. Note that the decimal point connection is not used in this demonstration.
  • Transistors Q1 through Q4 provide additional driving current to the LED segments. These transistors are recommended because each pin on the Arduino can source or sink only 40 mA of current. With seven segments of the display turned on at once (the numeral 8), the current demand can exceed this limit.
  • Resistors R8 through R11 serve to limit current to the base of each transistor.




Download Arduino Demo Code


To use this example, upload the following sketch to your Arduino. The display updates about once every quarter second, counting up the tenths of milliseconds since the sketch was started.

This sketch requires the use of a third-party library, Multiplex7Seg. It is included in the download with the example sketch. To use this library, if it’s running exit the Arduino IDE software, and move Multiplex7Seg folder to your Arduino sketchbook libraries folder. This is typically in (My) Documents\Arduino\libraries. Restart the IDE software, then load and run the sketch.

#include <Multiplex7Seg.h>

byte digitPins[] = {9, 10, 11, 12};         // LSB to MSB
byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8}; // Segment a to g
unsigned int adc;

void setup() {
  Multiplex7Seg::set(1, 4, digitPins, segmentPins);   // Initialize
  // See the example in Multiplex7Seg library for initialization parameters

void loop() {
  Multiplex7Seg::loadValue(millis() / 10);  // Display incrementing value