Piezo / headphone jack autodetect

92 views
Skip to first unread message

MerlinJim

unread,
Oct 28, 2009, 8:34:08 AM10/28/09
to Auduino
I'm building an auduino, and I wanted it to have both Piezo and
headphone options.

I think I can figure out when the headphone is attached, I'm using a
stereo 3.5mm socket, I have the two lines connected to pins 10 and 11,
I'll pull them high and then when they go low I'll know they're
connected, switch to output mode... haven't figured out how to detect
a disconnect yet, I could always just swap one of the pins to input
mode real quick and check... hopefully it won't create too much noise
or popping while the headphone is attached...

Any advice on the above would be appreciated... but here's the
question I really want to know...

how do I switch the PWM outputs?

I'm guessing this is what I change:

#define PWM_PIN 3
#define PWM_VALUE OCR2B
#define PWM_INTERRUPT TIMER2_OVF_vect

What values should I use for the headphone? I don't really care if,
for this version, I'm limited to mono output... I was hoping to clone
the PWM output on both pins 10 and 11
Reply all
Reply to author
Forward
0 new messages