A Seven Segment Display is an electronic display device used to represent decimal numbers and some letters. It consists of seven individual segments (labeled 'a' through 'g') that can be illuminated in different combinations to display digits from 0 to 9. Some advanced displays also include an eighth segment for a decimal point. These displays are widely used due to their simplicity and ease of interfacing with microcontrollers.
Below are the general technical specifications for a standard Seven Segment Display. Note that specific values may vary depending on the manufacturer and model.
The pin configuration for a standard 7-segment display (without a decimal point) is as follows:
Pin Number | Label | Description |
---|---|---|
1 | e | Controls segment 'e' |
2 | d | Controls segment 'd' |
3 | Common | Common Cathode (-) or Common Anode (+) |
4 | c | Controls segment 'c' |
5 | dp | Controls the decimal point (if available) |
6 | b | Controls segment 'b' |
7 | a | Controls segment 'a' |
8 | f | Controls segment 'f' |
9 | g | Controls segment 'g' |
Note: For a Common Cathode display, the common pin is connected to ground. For a Common Anode display, the common pin is connected to the positive voltage supply.
Below is an example of how to control a Common Cathode Seven Segment Display using an Arduino UNO.
// Define the Arduino pins connected to the segments
const int segmentPins[] = {2, 3, 4, 5, 6, 7, 8};
// Define the segment patterns for digits 0-9
const byte digitPatterns[] = {
0b00111111, // 0
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111101, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111 // 9
};
void setup() {
// Set all segment pins as OUTPUT
for (int i = 0; i < 7; i++) {
pinMode(segmentPins[i], OUTPUT);
}
}
void loop() {
// Display digits 0-9 in a loop
for (int digit = 0; digit < 10; digit++) {
displayDigit(digit);
delay(1000); // Wait 1 second before showing the next digit
}
}
// Function to display a digit on the 7-segment display
void displayDigit(int digit) {
byte pattern = digitPatterns[digit];
for (int i = 0; i < 7; i++) {
// Write HIGH or LOW to each segment based on the pattern
digitalWrite(segmentPins[i], (pattern >> i) & 0x01);
}
}
Segments Not Lighting Up:
Incorrect Digits Displayed:
Flickering Display:
By following this documentation, you should be able to successfully integrate and use a Seven Segment Display in your projects!