Overview
As a learning project I put together a multiplex 4 digit segment display. It takes serial input and displays the numbers it receives. The microcontroller reads the serial input and is in charge of powering the segments of the digits. Only one digit is on at any given time but they go on and off so fast it looks like they are constantly on.
There are 8 pins on the microcontroller each in charge of a segment. All of those segments are connected. Each digit is connected to a transistors. There are four pins of the microcontroller that each control a transistor. The digit only lights up if its transistor allows current to flow to ground. The microcontroller constantly turns “off” all transistors, sets the segment pins appropriately then turns on one of the transistors. It then turns off the transistors, sets new segment pins and turns on the next transistor. It does this over and over.
Why do this instead of just have the segments you want on to be on all the time? There are two main reasons:
- If you dedicate a microcontroller pin to each segment of each digit you run out of microcontroller pins real quickly (pins needed=segments per digit * digits). In our setup adding another digit only would require one extra pin to another transistor (pins needed=segments per digit+digits).
- Having on all segments draws a lot of power. With this setup only one digit’s segments are on at one time taking less power than if all of them were on.
Video
Schematic
Parts list
| Qty | Part | Store Link |
|---|---|---|
| 1 | ATMEGA 168 Microcontroller | |
| 1 | 28 pin socket | |
| 1 | 2×5 Male Header | |
| 1 | 4 Mhz Crystal Oscilator | |
| 2 | 22p Capacitor | |
| 1 | 1n Capacitor | |
| 4 | 2N3904 Transistor | |
| 4 | HDSP-303G segmented digit LED | |
| 8 | 400 Ohm resistor | |
| 1 | 10k Ohm resistor | |
| 4 | 1M Ohm resistor |
PCB
I made this board with ExpressPCB they don’t let you save in any other format so that you have to use them to make the board. Here is the file. Below are some images of it.
Code
This code tells the microcontroller to constantly blink the 7segments. It uses USART_RX_vect interrupt for when new data gets sent to it. 4digit-segment-code.zip
After Thoughts
- The spacing of the pads should be positioned so headers could be used.
- Use a PCB program that exports gerber files so you can use any PCB manufacturer
- PCBs with solder mask makes things much easier.





