Go Down

Topic: 4 Digit 7 segment LED Display Question (Read 3 times) previous topic - next topic

Chris7777

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 http://forums.adafruit.com/viewtopic.php?f=25&t=20305
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

Code: [Select]
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

dean8020

Hello,
Quote
it's a Common Cathode version if that matters.

Yes that does matter as it changes how you control the digits.

Quote
Code: [Select]
// pins 10 and 12 turn on the whole digit: HIGH is on

From this I assume pins 10 and 11 are connected directly to the common cathode of each digit?
If that is the case, as the cathode connects to ground, LOW would be on not HIGH.

And the same is true for the Anodes, they connect to positive supply, so HIGH is on and LOW is OFF.
Although having said that, the code seem's to be in the correct order, just your comments are wrong.

Code: [Select]
// Turn the Digits off
  digitalWrite(10, HIGH);   
  digitalWrite(12, HIGH);   

  // first digit, turn top bar on
  digitalWrite(7, LOW);   
  digitalWrite(2, HIGH);   
 
  // Turn on the Digit
  digitalWrite(10, LOW);
 
  // sleep
  delayMicroseconds(10000);


I'm not sure about the leakage, but if the digital output for the segment that is off, is still turning off when the digit is turned on, it may appear feint.

I would try adding a very small delay between setting the segments and switching the digit on.
Or of course wait for a more conclusive answer from an expert :P

Just what I would try while waiting :)

Dean

Grumpy_Mike

You need to post the schematic of how you have wired it up.
It sounds like you have no current limiting resistors and you are trying to drive too much current through the arduino pins, thus damaging it.

Chris7777


Thanks for the input Dean

I think I am wrong, I think the display is a Common Anoid, the part number on the display is AECE-5461AHO(O might be Zero tho)
I found this datasheet http://www.datasheetarchive.com/indexdl/Scans-004/Scans-0081690.pdf
which from the datasheet shows the A on the end of the part means it should be a Common Cathode however it seems to behave more like a Common Anoid,
I provide HIGH/Voltage to turn on the digit and then LOW/Ground the pins for each segment of that digit I want to light up. Or do I have that backwords?

I have included a schematic of how I have it hooked up.

Another question from that pseudo code I was using is why do I have to turn on all Digits to HIGH( ie "(1) All four cathodes high"), why cant I just send power to the one digit I want to light up, ground the pins/segments I want to make the number and move on to the next digit or change the current digit again? I messed around with that code trying different settings and I just cant make it work, any ideas?

Thanks
Chris

dean8020

Hi,

A quick test to see if it is common cathode or anode, as the pin out is the same for both models on the data sheet,  Connect 5v, through your resistor, to pin 1 of the package and gnd to pin 12, if a segment lights up it is common cathode, if not swap the connections (5v to 12 ground to 1) and the segment should then light up and it is common anode.

I am confused as to how you have wired it up though,
Either it is wired differently to your diagram or it is not the correct datasheet or the pins are numbered in a very unconventional way.

You say you have the top bar and bottom bar active, using pins 2 and 7 of the arduino.

The top bar is segment 'A' and the bottom segment 'D' on pins 11 and 2 of the display, the package in the data sheet is 12 pins (1 row of 6 each side) so pin 11 and 2 should be on opposite sides to each other...

Go Up