This schematic shows what I think you mean and might work for you.
The 22K is the recommended value when connected directly to RS232 voltage levels like this. The uC internal protection diodes already clamp the input signal to Vdd so the Zener is a safe option and won't start to conduct until the input approaches the rated value.
I can't remember my voltage divider formula when it comes to introducing the 12V like this, but the results will be:
Switch OFF : Vout = 2.5V
Switch 12V : Vout = Somewhere between 2.5V and 5V
Switch GND: Vout = Somewhere between 2.5V and GND
Maybe someone can fling it mathematically or plug the values into their Proteus simulator to help me out.
As far as the A/D module running in the background. It does, but you still have to start it with some code and I believe the only interrupt indication you get is the ADIF when the read is complete which is pretty fast anyways, in the us.
Bookmarks