Hey there! I’m a supplier of 7 Segment LCDs, and I often get asked about how to display a pattern of numbers on these nifty little devices. So, I thought I’d share some insights on this topic. 7 Segement LCD

First off, let’s understand what a 7 Segment LCD is. It’s a display that consists of seven segments, usually in the shape of an ‘8’, and sometimes with an additional decimal point. These segments can be lit up in different combinations to form numbers from 0 to 9, as well as some letters.
Understanding the Basics of 7 Segment LCDs
To display a number on a 7 Segment LCD, you need to know which segments to light up. Each segment has a specific name – usually labeled a, b, c, d, e, f, and g, and sometimes the decimal point is labeled as dp.
For example, to display the number ‘0’, you need to light up segments a, b, c, d, e, and f, leaving segment g off. Here’s a quick breakdown of how to display each number from 0 to 9:
- 0: a, b, c, d, e, f
- 1: b, c
- 2: a, b, g, e, d
- 3: a, b, c, d, g
- 4: b, c, f, g
- 5: a, c, d, f, g
- 6: a, c, d, e, f, g
- 7: a, b, c
- 8: a, b, c, d, e, f, g
- 9: a, b, c, d, f, g
Driving the 7 Segment LCD
Now that we know which segments to light up for each number, the next step is to actually drive the LCD. There are a few different ways to do this, and I’ll go over the most common ones.
Using a Microcontroller
One of the most popular ways to drive a 7 Segment LCD is by using a microcontroller, like an Arduino. Microcontrollers are great because they’re easy to program and can handle multiple tasks at once.
To connect a 7 Segment LCD to a microcontroller, you’ll need to connect each segment (a – g and dp) to a digital output pin on the microcontroller. You’ll also need to connect the common pin (either common anode or common cathode) to the appropriate power source.
Here’s a simple example of how to display the number ‘5’ on a 7 Segment LCD using an Arduino:
// Define the pins for each segment
const int a = 2;
const int b = 3;
const int c = 4;
const int d = 5;
const int e = 6;
const int f = 7;
const int g = 8;
void setup() {
// Set all segment pins as output
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
}
void loop() {
// Turn on segments for number 5
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
delay(1000); // Wait for 1 second
}
Using a 7 Segment Display Driver
Another option is to use a 7 Segment display driver, like the MAX7219. These drivers can simplify the process of driving a 7 Segment LCD, especially if you’re using multiple displays.
The MAX7219, for example, can control up to 8 digits of 7 Segment displays with just a few pins. It communicates with the microcontroller using a serial interface, which makes it easy to send data to the display.
Here’s a simple example of how to use the MAX7219 to display the number ‘5’ on a 7 Segment LCD using an Arduino:
#include <LedControl.h>
// Define the pins for the MAX7219
const int DIN = 12;
const int CS = 11;
const int CLK = 10;
// Create an instance of the LedControl library
LedControl lc = LedControl(DIN, CLK, CS, 1);
void setup() {
// Initialize the MAX7219
lc.shutdown(0, false);
lc.setIntensity(0, 8);
lc.clearDisplay(0);
}
void loop() {
// Display the number 5 on the first digit
lc.setDigit(0, 0, 5, false);
delay(1000); // Wait for 1 second
}
Displaying Patterns and Sequences
Once you know how to display individual numbers, you can start creating patterns and sequences. For example, you could display a countdown timer, a scrolling message, or a random sequence of numbers.
To display a countdown timer, you could use a loop to decrement a variable and display the new number on the 7 Segment LCD. Here’s an example:
// Define the pins for each segment
const int a = 2;
const int b = 3;
const int c = 4;
const int d = 5;
const int e = 6;
const int f = 7;
const int g = 8;
void setup() {
// Set all segment pins as output
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
}
void loop() {
for (int i = 9; i >= 0; i--) {
displayNumber(i);
delay(1000); // Wait for 1 second
}
}
void displayNumber(int num) {
switch (num) {
case 0:
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, LOW);
break;
case 1:
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
break;
// Add cases for the remaining numbers
default:
break;
}
}
Conclusion

Displaying a pattern of numbers on a 7 Segment LCD can be a fun and rewarding project. Whether you’re using a microcontroller or a display driver, there are plenty of options available to suit your needs.
TFT LCD If you’re interested in purchasing 7 Segment LCDs for your projects, feel free to reach out. We offer a wide range of high-quality 7 Segment LCDs at competitive prices. Our team is always ready to help you find the right product for your application.
References
- Arduino Documentation
- MAX7219 Datasheet
Chenxin Optoelectronics Co.,Ltd
As one of the most professional 7 segement LCD manufacturers and suppliers in China, we’re featured by quality products and low price. Please feel free to wholesale cheap 7 segement LCD made in China here from our factory. Contact us for customized service.
Address: 3 / F, building 5, standardization plant, Yangtang science and Technology Logistics Industrial Park, Hecheng industrial concentration zone, Hecheng District, Huaihua China
E-mail: admin@zgcxgdlcd.com
WebSite: https://www.zgcxgdlcd.com/