The 5643AS is a 7-segment display commonly used in electronic projects for displaying numerical information. Each segment consists of a single LED, and by controlling which LEDs are lit, it can represent the numbers 0 through 9. This component is widely used in digital clocks, electronic meters, and other devices that require a simple numeric display.
Pin Number | Segment | Description |
---|---|---|
1 | E | Controls the bottom-left LED segment |
2 | D | Controls the bottom LED segment |
3 | Common Anode | Connected to the positive voltage supply |
4 | C | Controls the bottom-right LED segment |
5 | DP | Controls the decimal point LED |
6 | B | Controls the top-right LED segment |
7 | A | Controls the top LED segment |
8 | F | Controls the top-left LED segment |
9 | G | Controls the middle LED segment |
10 | Common Anode | Connected to the positive voltage supply |
// Define the Arduino pins connected to the segments A-G and DP
const int segA = 2;
const int segB = 3;
const int segC = 4;
const int segD = 5;
const int segE = 6;
const int segF = 7;
const int segG = 8;
const int segDP = 9;
// Define the digit to segment mapping for common anode displays
int digits[10][7] = {
{0,0,0,0,0,0,1}, // 0
{1,0,0,1,1,1,1}, // 1
{0,0,1,0,0,1,0}, // 2
{0,0,0,0,1,1,0}, // 3
{1,0,0,1,1,0,0}, // 4
{0,1,0,0,1,0,0}, // 5
{0,1,0,0,0,0,0}, // 6
{0,0,0,1,1,1,1}, // 7
{0,0,0,0,0,0,0}, // 8
{0,0,0,0,1,0,0} // 9
};
void setup() {
// Set all the segment pins as outputs
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
pinMode(segDP, OUTPUT);
}
void loop() {
for (int digit = 0; digit < 10; digit++) {
displayDigit(digit);
delay(1000); // Display each number for 1 second
}
}
// Function to display a single digit on the 7-segment display
void displayDigit(int digit) {
int *segments = digits[digit];
digitalWrite(segA, segments[0]);
digitalWrite(segB, segments[1]);
digitalWrite(segC, segments[2]);
digitalWrite(segD, segments[3]);
digitalWrite(segE, segments[4]);
digitalWrite(segF, segments[5]);
digitalWrite(segG, segments[6]);
// Note: DP is not used in this example, but can be controlled similarly
}
Q: Can I use a 5643AS display with a 5V Arduino? A: Yes, but ensure you use appropriate current-limiting resistors to protect the LEDs.
Q: How can I control multiple 7-segment displays? A: You can use multiplexing or a dedicated driver IC to control multiple displays with a limited number of microcontroller pins.
Q: What is the purpose of the decimal point (DP)? A: The DP can be used to display decimal points in numbers, useful in applications like digital clocks or readouts that require a decimal point.