I was at my local electronics store today and I was going to buy a 1 digit 7 segment display but I spotted the 4 digit one for only a bit more so I went for it. I have a question about displaying different numbers on different digits. Turns out it’s a Common Cathode version if that matters. It took me a while(read lots of googling) to get it wired up right and kinda working. I didn’t want to just grab some code or a library; I wanted to play around with it myself to better understand it. Right now I have it wired up to just use two digits with one digit displaying a bar at the top and one a bar at the bottom. This is working but I can see just a faint bit of bleed over, for example the digit with the bottom bar on has its top bar on ever so faintly. What I wanted to know is, is this par for the course when powering a display this way or is my code not the best?
My Code is following some sudo code I found here 4-Digit 7-Segment LED - adafruit industries
In loop():
(1) All four cathodes high
(2) Desired anodes for the first digit high
(3) Cathode for first digit low
(4) Delay
Repeat for digit 2
void setup() {
pinMode(7, OUTPUT);
pinMode(2, OUTPUT);
pinMode(10, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
// pins 10 and 12 turn on the whole digit: HIGH is on
// pins 2 and 7 turn on the top and bottom bars: HIGH is off
// Turn the Digits on
digitalWrite(10, HIGH);
digitalWrite(12, HIGH);
// first digit, turn top bar on
digitalWrite(7, LOW);
digitalWrite(2, HIGH);
// Turn off the Digit
digitalWrite(10, LOW);
// sleep
delayMicroseconds(10000);
// repeat for digit 2
digitalWrite(10, HIGH);
digitalWrite(12, HIGH);
// second digit turn bottom bar on
digitalWrite(7, HIGH);
digitalWrite(2, LOW);
digitalWrite(12, LOW);
delayMicroseconds(10000);
}
Thanks
Chris