Quick question about current draw

Is there a way to detect whether or not a pin set as OUTPUT is actually being drawn from

Example.
Lets take a simple LED

case 1.
LED cathode = pin 8
LED anode = pin 9

case 2.
LED cathode = pin 9
LED anode = pin 8

in my setup i set pin 8 and 9 as OUTPUT

lets say that by default my program runs for anode on pin 9
digitalWrite(8, LOW);
digitalWrite(9, HIGH);

is there a way to test if current is actually being drawn from pin 9?
and if not, then reverse and set

digitalWrite(8, HIGH);
digitalWrite(9, LOW);

thanks in advance for tips, hints, tricks and such

You could measure the voltage across the current limiting resistor with an analogue input.

You could check the datasheet and see if an ADC pin can be used as a digital output
and an analog input. Depending on the current you may be able to measure the voltage drop across the output transistor. This would give you a few pins.

(* jcl *)


www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org

the resistor idea sounds like it may work
will try it out

You could check the datasheet and see if an ADC pin can be used as a digital output

Yes it can. Just refer to A0 as pin 14, A1 as pin 15 and so on.

Yes it can. Just refer to A0 as pin 14, A1 as pin 15 and so on.

At the same time? If you could force the output to a high or low value and
then measure the voltage drop across the output transistor you would
know if current is flowing.

(* jcl *)

At the same time?

No the output stage is not built like that. You have to do some external stuff like a resistor or bridge rectifier.