Feedback!

4 x 7 Segment LED Breakout Board

Views: 12893 Difficulty: 1 Status: Development
4x7segment_led_w_arduino_main

Display 4 digits using only 3 MCU wires with the 4 x 7 Segment LED and shift register breakout board.

Need numbers in your next project? Maybe you're building an electronic score board, or an Arduino-based clock. The 4 x 7 Segment LED breakout board allows you to display four digits using only 3 wires on your microcontroller. You can buy one here. The displays come in blue and red. Controlling four 7-Segment LEDs requires individual control of 4 x 7 = 28 distinct LEDS. We achieve this by daisy chaining 4 74HC595 Shift registers together, with each shift register in control of one digit as in the breakout board for the single 7 Segment LED. We use this LED module in our DIY LED clock tutorial.

4 x 7 Segment LEDs and Arduino

4x7segment_led_w_arduino
Easy to drive with an Arduino just use the sample code below.

The 4 x 7 Segment LED Block in action

Checkout the LED block in action. The code running on the module is explained and shared below. Count to one thousand and then do it again and again and again...

Step-by-Step Instructions

Step 0 Apply Solder to all Pads

First use a flux pen on all the pads you are going to solder. Then apply solder to every pad on the side of the PCB labelled LucidTronix. Make sure you have no solder bridges connecting two pads.

Step 1 Add Shift Registers in the Correct Orientation

First Heat up the pads for the chip with the hot air gun. Wait until the solder changes color, and gets a little more shiny. Then grab the 74HC595 chip with tweezers and ensure the circle indentation is lined up with the silkscreened 1 on the PCB. While still applying the hot air lay the chip down on its pads. The surface tension of the solder should look it into place.

Step 2 Solder Again

We've found it's a good idea to do a second round of soldering after getting the chip in place with the hot air gun. Spread some flux on the pins and quickly touch them with the iron. This ensures a solid connection between the pins and the pads.

Arduino code for 7-segment LEDs controlled by 74HC595 shift registers

This code will count to one thousand over and over again. We display numbers on the 7-segment displays easily by storing the LED configuration for the different numbers in the array of bytes called dec_digits:
byte dec_digits[] = {0b11000000,0b11111001,0b10100100,0b10110000,0b10011001,0b10010010,0b10000011,0b11111000,0b10000000,0b10011000 };
Then we have 4 nested for loops for the ones, tens, hundreds, and thousands columns. Each for loop goes to ten which is how many decimal digits we have... Hmmm.. we also have ten fingers, coincidence? No way! Then to display the numbers on the shift registers we use the Arduino shiftOut function.
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[onesColumn]);
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[tensColumn]);
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[hundredsColumn]); 
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[thousandsColumn]);
Notice that we send the ones column out first as this is the shift register furthest from the Arduino. We also must make sure to take the shit register's latch pin low before we send out any data and then set it to high again to put the shift registers in output mode so we can see the updated numbers.
/* LucidTroniX
 * Daisy Chained Shift Registers
 * 4 74HC595 shift registers connected to 
 * 4 x 7 Segment LED Breakout Board
 * Tutorial at:
 * http://www.lucidtronix.com/tutorials/50
 * September 2013
 */
 
int dataPin = 5;
int latchPin = 6;
int clockPin = 7;

byte dec_digits[] = {0b11000000,0b11111001,0b10100100,0b10110000,0b10011001,0b10010010,0b10000011,0b11111000,0b10000000,0b10011000 };

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
  for (int thousandsColumn = 0; thousandsColumn < 10; thousandsColumn++) {
    for (int hundredsColumn = 0; hundredsColumn < 10; hundredsColumn++) {
      for (int tensColumn = 0; tensColumn < 10; tensColumn++) {
        for (int onesColumn = 0; onesColumn < 10; onesColumn++) {
          // take the latchPin low so 
          // the LEDs don't change while you're sending in bits:
          digitalWrite(latchPin, LOW);
          // shift out the bits:
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[onesColumn]);
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[tensColumn]);
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[hundredsColumn]); 
          shiftOut(dataPin, clockPin, MSBFIRST, dec_digits[thousandsColumn]);
          //take the latch pin high so the LEDs will light up:
          digitalWrite(latchPin, HIGH);
          // pause before next value:
          delay(50);
        }
      }
    }
  }
}

Parts

Title Description # Cost Link Picture
PCB 4x7 Segment LED Breakout Printed circuit board for our 4 x 7 segment LED shift register breakout board. 1 $6.0 Link 4x7segement_led_pcb
LED Display 7 Segment numeric LED Display RED Value: 7 Red LEDs 4 $0.95 Link 7segmentredled-01-l
Shift Register IC SHIFT REGISTER 8BIT 16-SOP Tri-State Serial to Parallel Value: 74HC 4 $0.65 Link Screen_shot_2012-12-28_at_7.32.29_pm
Capacitor CAP CER 0.1UF 50V Y5V 0805 Value: 0.1µF 4 $0.1 Link 0805(6_0mm_thickness)
Resistor Array RES ARRAY 300 OHM 4 RES 1206 Value: 300 8 $0.02 Link Vishay_-_cra06s-8
Permalink: http://lucidtronix.com/tutorials/50
The 74HC595 shift register controls a 10 LED Bar Graph....
Connect shift registers together to get more output and input pins from your microcontroller....
Build your own clock with the MCP79410 chip and 4 7-Segment LED modules....
Display numbers in big bright red LEDs use only 3 micro-controller pins and the 74HC595 shift registe...
32 buttons for a fully-functioning hand-held USB keyboard....
A QWERTY keyboard you build yourself....
Two LED matrices give 70 LEDs to light up a necklace with messages....
Make an interactive light show using a proximity sensor, and a bunsh of shift registers and LEDs....