Reputation: 1041
I have a 3.5 digit 7-segment LED display which I am trying to drive with an Arduino. The Arduino runs a shift register with a latch (M74HC595). The 8 outputs of the shift register go through 2000Ohm resistors and into the 8 segment pins of the display. The three digit controlling pins of the display go to three pins on the Arduino. The display has a common-cathode, so that when a control pin is LOW, the digit is on, and when it's HIGH, the digit is off.
This works fine as long as I only light up a single digit, or light up multiple digits with the same segments, but once I try to switch the segments between two or three digits, it all gets messed up. Segments that shouldn't have light in them, instead have a weak light, which bothers with reading the actual number.
If I add delays between writing to each digit the unwanted lights dim some more, but soon enough the whole thing blinks because of high delays and is unusable.
Am I doing something wrong?
To enable a specific digit, I set the controlling pins on the Arduino, for example this is how I enable the first digit:
digitalWrite(digit1, LOW);
digitalWrite(digit2, HIGH);
digitalWrite(digit3, HIGH);
Then to push a number to the shift register and move it to the latch (and hence to the display):
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
This is my scheme:
Upvotes: 0
Views: 4465
Reputation: 41928
First, you should enable the digit through the common pin only after your output is ready. Second, it looks like you're switching digits with pins enabled, and you're changing them after the digit became visible, hence why you get dimmed lights when using different digits.
You should follow a loop like this.
The idea is that the 3 digits will actually be blinking very fast, but for human eyes it looks like they're on all the time. If you enable them first, there will be a value from the last digit on the 74595 output, and that will be visible for a fraction of time. When you switch to the actual value, it will look dimmer, since it's visible for less time. When the number is the same, it looks like there's nothing wrong.
Upvotes: 2