Design a Digital Clock Using 7 Segment Displays
7 Segment display is one of the oldest methods of displaying values in electronic devices. The combination of 7 LEDs makes the whole display. Every time a single pin gets the power of a specific range it starts glowing. The pattern and drawing of LED make the decimal digit 8. Then turning on/off the specific pins make the 7-segment to show the other decimal numbers. The LED has a total of 10 input pins. It also comes in two types; one is the cathode and the other one is the anode. In both types, one gives the common anode and the other has a common cathode. The 7-segment is useable directly by any low voltage device.
Seven Segment Display Pin Configurations
The 7-segment has the simplest pin configuration. These pins are easy to use directly with any microcontroller or microprocessor. It is easy to use and easy to check with simple power input. All the pins of the display device are:
7- Segment Display Pinout Diagram Details
This section lists the description of all pins for both common anode and common cathode types.
PINS | Details | |
---|---|---|
Pin1 | e | The first pin1 connects with the left bottom LED of the display. |
Pin2 | d | Pin2 helps to light up the bottom-most led. |
Pin3 | com | This pin will common with ground/power. It depends on the type of the 7-segment either it is the common cathode or anode. |
Pin4 | c | Pin4 light up the bottom right led to the display |
Pin5 | DP | There is a decimal point on the 7-segment which uses the pin5 to light up. |
Pin6 | b | It controls the right top led light. |
Pin7 | a | The top led of the 7-segments is at pin7. |
Pin8 | com | Pin8 is a second common ground pin, works like same as pin3. |
Pin9 | f | Top-left led lights up through pin9. |
Pin10 | g | Power input on pin10 lights up the middle led. |
Internal Structure of 7 Segment Display
In the 7-segment display, the simple LEDs uses to display the decimal character. In the device, all the LEDs are placed at a 90-angle from minium two LEDs. One pin of all the LEDs is common. That pin decides when the anode is common or cathode. Then all the other pins come out of the package as a single pin for each LED. Whenever any pin gets the power input of specific voltages then it starts glowing. The specific dark color case is used to limit the LED light to itself. The light from one led won't affect the other and gives a clear and clean output. The LED's power limit is according to the other simple LED lights. It also uses the resistor for power protection.
Decimal Point
In some 7-segment the decimal point is also available. But it is not available in all displays. The decimal point just increases the one number in the pins. The rest of the circuit of the decimal point remains the same as the other LEDs. The availability of the decimal point is to represent the decimal values.
How to use Seven Segment Display?
The use of 7-segments is simple with every kind of device and board. So, the 7-segment only requires to get the input signal at input pins for each led. It only requires a specific circuit and component to make the 7-segment safe. Add the resistor of 220 ohms at each input pins. The resistors will lower down the voltages but the value 220ohm is only for 5V output devices. The increase in voltage will lead to an increase in resistors. The circuit will according to the following diagram:
To use the LED there are two methods, one is IC which will take the 4-inputs and will able to generate the output data from 0-9 and it can also show some alphabets on the 7-segments.
7 Segment Truth Table
DECIMAL | INPUTS | ||||||
---|---|---|---|---|---|---|---|
a | b | c | d | e | F | g | |
0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
2 | 1 | 1 | 0 | 1 | 1 | 0 | 1 |
3 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |
4 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
5 | 1 | 0 | 1 | 1 | 0 | 1 | 1 |
6 | 0 | 0 | 1 | 1 | 1 | 1 | 1 |
7 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
8 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
9 | 1 | 1 | 1 | 0 | 0 | 1 | 1 |
The above truth table will decide the output from the input pins. Therefore, it depends on the designer which methods the system can use at a cheap cost.
Seven Segment Driver IC
Multiple ICs are useable with the display to operate with only a small number of pins. Therefore, The IC will always depend on which type of display we are using. The use of IC will also be by the resistors because the most operating voltage uses with CMOS/TTL devices are 5 volts. The input on the IC will be in binary form and output will also in binary form too. A single IC will only able to operate the single display. Therefore, some IC comes with an extra pin which helps to make the circuit of multiple 7-segment with IC.
To use the multiple IC always verify the truth tables. In the use of IC, the input and output signal will always be hardware-based. Therefore, to add the programming to control the 7-segment a programmable boards/devices are attachable. You can check this complete driver example:
- 74LS48 BCD to 7-Segment decoder complete guide
How to write Program for 7-segment Display?
To use the 7-segment through programming any low voltage device is useable. The most common one is microcontroller and Arduino. Here we will use the Arduino with 7-segment to display the data from programming.
To display the data by GPIO pin are useable but in programming, there are simple and complex methods. Let's understand what is the goal of through programming. To tun on a single LED, there should only HIGH output from those pins. The following command will help:
digital.Write(PIN_NUMBER, HIGH); //It will perform the HIGH output signal at GPIO pins digital.Write(PIN_NUMBER, LOW); //It will perform the LOW output signal at GPIO pins
The above command will turn on the LED but display multiple digits the data will become complex. Therefore, to make it simple in every programming use the array to store the data in an array and then call the data in the form of a loop. So, then the data complexity will at the array only. Here is the example
int arduinoPins[] = {a, b, c, d, e, f, g, h }; // change them according to the 7-segment of the LED to the Arduino. byte segCode[10][8] = { { 1, 1, 1, 1, 1, 1, 0, 0}, //Decimal Digit 0 { 0, 1, 1, 0, 0, 0, 0, 0}, //Decimal Digit 1 { 1, 1, 0, 1, 1, 0, 1, 0}, //Decimal Digit 2 { 1, 1, 1, 1, 0, 0, 1, 0}, //Decimal Digit 3 { 0, 1, 1, 0, 0, 1, 1, 0}, //Decimal Digit 4 { 1, 0, 1, 1, 0, 1, 1, 0}, //Decimal Digit 5 { 1, 0, 1, 1, 1, 1, 1, 0}, //Decimal Digit 6 { 1, 1, 1, 0, 0, 0, 0, 0}, //Decimal Digit 7 { 1, 1, 1, 1, 1, 1, 1, 0}, //Decimal Digit 8 { 1, 1, 1, 1, 0, 1, 1, 0} //Decimal Digit 9 }; void setup() { } void loop() { for (int i=0; i < 8; i++) digitalWrite(arduinoPins[i], segCode[n][i]); //n will help to change each variable }
There is also another method which is using functions. However, the functions will also save time once they are designed. Each function will use the high/low signal control commands in them. Therefore, it is still larger as compare to the array. The use of functions and array will save the data complexity but it is still a costly project in case of pins numbers. So, to minimize the pins numbers a third method will solve the issue.
Hybrid Method
The hybrid method will solve the PINs issue. In this method, the 7-segment will connect through the IC to the microcontroller/microprocessor. Therefore, the IC will take the four inputs from the Arduino and then it will transfer the input in the form of 7-segment output. The input will be in binary digits form and output will be according to the 7-segment. The following code will help to design the display with 4-pins:
int IC_Pins[] = {D, C, B, A}; // define the IC input pins here byte bcdCode[10][4] = { { 0, 0, 0, 0}, //Decimal Digit 0 { 0, 0, 0, 1}, //Decimal Digit 1 { 0, 0, 1, 0}, //Decimal Digit 2 { 0, 0, 1, 1}, //Decimal Digit 3 { 0, 1, 0, 0}, //Decimal Digit 4 { 0, 1, 0, 1}, //Decimal Digit 5 { 0, 1, 1, 0}, //Decimal Digit 6 { 0, 1, 1, 1}, //Decimal Digit 7 { 1, 0, 0, 0}, //Decimal Digit 8 { 1, 0, 0, 1} //Decimal Digit 9 }; void setup() { } void loop() { for (int i=0; i < 4; i++) { digitalWrite(IC_Pins[i], bcdCode[digit][i]); //digit will needs to change according to the decimal digits } }
The above code will generate the output according to the input signals. The only problem in using all three methods will have some consequences at each end. Therefore, the cheapest method is with IC with 7-segment. The hybrid method will increase the cost and even the size of the project. To use any of the single methods always keep in mind about cost and size, it will help to understand which method is suitable for the project.
Tutorials
You can also check these tutorials.
- Seven segment display interfacing with Arduino: Multiple
- SEVEN SEGMENT DISPLAY COUNTER USING PIC16F877A MICROCONTROLLER
Seven Segment Display Features
- The 7-segment is interfaced able with almost every module /device.
- It requires 3V to power on, otherwise at low and high both state the LED will on. Sometimes it could burn.
- The current only passes from one side to the other due to its internal structure.
- A single device can show up to 10 decimal digitals on a single display.
- The display is useable to show multiple digits. So, every time the number of the display will increase.
Applications
- The device has vast use in most old and modern devices.
- The simple calculators use 7-segments too.
- The voltmeters at a commercial level for home use the 7-segment display.
2D Diagram
Alternative Display Module
- Monochrome 0.96" OLED Display
- Nokia5110 LCD Module
- 2.4″ TFT LCD Display Module overview
- TFT Display
- TM1637- Grove 4 Digit Display Module
- 16×2 LCD Module – Liquid Crystal Display
Other Electronics Components:
- LM311 Differential Comparator IC
- LF351 Single Operational Amplifier
- DS1302 Real Time Clock (RTC) Chip
- HT12E RF Encoder IC for wireless communication
- SG3525 Pulse width modulation controller IC
- MPSA42 NPN Transistor
- PIC16F676 Microcontroller
- 2N3906 PNP Transistor
- AD620 Low Cost Low Power Instrumentation Amplifier
- NEMA 23 Stepper Motor
Design a Digital Clock Using 7 Segment Displays
Source: https://microcontrollerslab.com/7-segment-display-pinout-working-examples-applications/
0 Response to "Design a Digital Clock Using 7 Segment Displays"
Post a Comment