Detect connected LED?

I was thinking..
Is it possible (and if: how) to use a I/O-pin to first detect if a led is connected(via ADC?) and then turn over to a output and controll the led as normal?

Ideas are more than welcome.
 

MartinM57

Moderator
Assuming pin-R-LED-Gnd, easier to make the pin an output, turn it high, measure the R-LED point with an ADC pin to see if it's circa 2v (or whatever). If it's circa Vcc there's no LED (or an open circuit one), it it's circa 0v it's a short circuit LED.

But not really understanding WHY you want to do this...
 
Thanks! Good idea!
I`m making a "memory-stick" with a 24lc128 eeprom and some dip-switches (to set addres,Write-protect and autodetect.).
On this board i want a "Do not remove LED" and a way of detecting when the board is inserted. The reason why i need to combine this functions is that i want to use a connector that is impossible to insert the wrong way(DINCON or similar.) and when the pincount rises the price and size rises too(The board is smd only.).
Now, if i wanted that the resistor was on the "memorystick" aswell?
Any more ideas?


Schematic:
R6=wire-link
R3=LED
 

Attachments

hippy

Ex-Staff (retired)
Any line which is pulled-up or down when the external module is inserted can be used to detect if the module is inserted or not.

If the module doesn't drive the LED directly, which is likely the case if you want to turn the LED off when it's safe to remove the module, you could probably use the SCL or SDA lines. A 100K pull-down will read 0V when not connected, with the board connected that will read nearer +V. That may allow what's required on the module to be reduced.
 

Dippy

Moderator
I think I'd something similar to hippy.

On my EEPROM board I'd have a 5K6 pullup on the WP pin.
On my PICAXE board I'd have a 100K pulldown on the pin that talks to WP.
My code would set that pin to input.
No EEPROM board means 0V (0/Low) on that pin.
EEPROM board plugged in would read 1/High.
When my code detected that pin had gone high it would mean that the EEPROM board was plugged AND while I was fiddling around the WP would be enabled.
Then, for writing, my code would set the pin to Output and toggle it during the write. Then set it high or input-mode again for sensing removal of board.

You could do a similar plug-in detection with the pin-res-LED-gnd on the EEPROM board. And 100K pullup on PICAXE pin in input mode and you read the pin status.
Then your code changes pin to Output and flashes your LED.
Use code - saves pins.
 
Thank's a lot for the suggestions!
Now i want even more features :eek:
But hopefully I have managed to work it out by myself.
The idea is to control the write protect pin together with the "do not remove LED"

So as i understand it, the pullup(R6) makes the picaxe read a 1 when the board is disconnected. When the board is connected the WP pullup is high and the picaxe sees a zero(pulled down through the led?), makes the pin an output high. Then current flows to the base resistor of the transistor, pulls the WP to gnd(Enable write) and at the same time current flows trough the led and it shines.

Does this make any sense at all?

Schematic:
TP1-TP2= Wirelink to Base
TP3-TP4= Wirelink to V+

R1-R2= 4,7K I2C Pullup
R3,R5= LED resistors (value to be choosen later)
R4 = 100n capacitor
R6 = 100K pullup for PicAxe I/O pin
R7 = WP pullup (I would guess it should be around 10K?)
R8 = Base resistor for transistor BC547C (not sure what value)
 

Attachments

Dippy

Moderator
"Does this make any sense at all?"

- Sorry, not to me :confused:
I'm sure you'll get there without making a simple project overcomplicated.
Good luck.
 
Top