I’m developing an Arduino Mini Pro sketch that will take a number presented through a BCD switch and display that number on EITHER a 7-segment display OR a series of 6 discrete LEDs. The design is such that the 7-segment and the 6 LEDs will be connected to the same digital pins of the arduino – but NOT at the same time. That is to say, only ONE of the display types can be connected at a time and I’d like the sketch to automatically detect and configure the run-state of the software according to the type of display attached. If no display is connected, I’d like the sketch to disable the display code at run time.
The 7-segment display will be connected like this:
I am connecting the display’s common cathode to digital pin 6 of the arduino to allow for PWM intensity control. In a similar manner, the 6 discrete LED display will share 6 of the 8 pins, as well as the common cathode return.
I have determined a method to detect whether one or the other displays are connected. I’ll measure the voltage present at the junction of the current limiting resistor R1 and Segment-A on the 7-segment display. This digital pin is not in common between the displays. If I measure 5V, then the 7-segment display is not connected. If I measure 1.6-2.4 volts, then the display is connected. I can do the same for resistor R2 and Segment-B. If I measure voltage drop on this junction, the 6 discrete LED display is attached.
I could assume that no voltage drop on either junction means no display is attached, but I’d like some way to detect current returning through digital pin 6. This would give the sketch a means to determine that no display is connected. Since there is no current limiting resistor, I can’t use the voltage drop method. Are there other ways to measure current on a digital pin?