PDA

View Full Version : One analog Pin - fed from 5 way joystick tactile switch - with interrupt?



HankMcSpank
- 18th January 2011, 00:36
The net abounds with circuits showing how to connect a 5 way tactile switch using a potential divider (resistor ladder) to a PIC/Arduino etc .....good stuff.

To give you a general vibe of the sort of switch I seek, it's gonna be something like this...

http://www.sparkfun.com/products/10063

But what I (think) I need is a way of generating an interrupt for such a joystick type switch....so that when any one of thos axises are pressed, I get an interrupt - but I can't see how that can be achieved with only one switch pole 'per axis'? So I seek a space saving 5-way joystick type switch, but with one pole always closing (to generate an interrupt)...the other pole to interface with the potential divider (feeding an analogue pin)

Or am I missing something....how do others use such 5-way tactile switches? (are they not meant to be used with interrupts?).

Anyone know of a suitable metod &/or switch?

cncmachineguy
- 18th January 2011, 01:33
Hi Hank, not sure why you can't just poll the A/D, but heres an idea. If your chip has compare on the same pin(s) as A/D (like '877) set the comparater up to interupt when any switch is pressed. then switch to A/D on that pin and read the value. after switch back to comp and wait.

HankMcSpank
- 18th January 2011, 11:23
Hi Hank, not sure why you can't just poll the A/D, but heres an idea. If your chip has compare on the same pin(s) as A/D (like '877) set the comparater up to interupt when any switch is pressed. then switch to A/D on that pin and read the value. after switch back to comp and wait.


Re using a comparator - that's a mighty fine idea.

re polling ......not sure I've totally understood what you're getting at (I'm still a n00b at heart!), do you mean constantly poll the analogue pin connected to the nav switch to see if there's been a meaningful change in voltage? (thereby meaning a switch has been pressed) If so, my program already has a good few loops with 'pause' commands gratuitously used throughout.

I guess during the waiting periods (ie pauses), I could be checking the incoming switch potential divider level to check for a change in voltage ....maybe it's my poor programming approach, but I've always has snappier results with interrupts (vs polling)