Detecting if headphone is plugged in.

Status
Not open for further replies.
You'd first need to get a headphone jack with the extra switches inside, which connect or disconnect when the plug is inserted.

If using the audio shield, the headphone ground is actually a 1.6 volt DC output, and the 2 signals have 1.6V DC offsets. If the switch connects another pin to the headphone ground, you could just look for 1.6V. If the switch connects the audio signals, you could use a low-pass filter to remove the higher frequencies and then look for 1.6V DC. Probably add a pulldown resistor, like 100K, so the pin goes to zero volts when the switch inside the jack disconnects it. You could build a circuit or just use one of Teensy's ADC pins to read the voltage. If it's low-pass filtered audio, of course the number will vary quite a lot from the 1.6V level, but you still should be able to tell the difference between audio and no signal, if you look at several measurements.
 
Status
Not open for further replies.
Back
Top