So I have a PIC 18 and I'm looking to use a single pin to control/sense the state of an external light bulb.
I figure the I/O pin would need to be set as an input to sense the state of the bulb and the it would also need to be set in software as an output to control it, or would it be easier to get done using external components?
Since the light bulb likely takes many 100;s of mA to drive it, and the PIC pin can source/sink a max of 25mA, you will definitely need an external transistor to switch the lamp on/off.
Where does the requirement to sense the state of the lamp using the same PIC pin stem from? Are you trying to detect if the bulb is burned out?
The requirement is that I want to save some pins, but this might just make my project a little complex. I might just see how it works with 5 pins as inputs and 5 pins as outputs. Might make my life easier.
I have the circuit to turn the light on/off and sense the state and if the bulb is burnt, but I'll have to be using two pins per bulb; one to sense and one for control.