I've already tried the "ball" type tilt switches from Sparkfun - but the closure isn't clean at all. Even with a decent debounce routine in my code the switch still sends lots of "phantom" signals. Have tried it with 2 different ones.
Wondering if anyone (a) has dealt with the ball tilt switches and knows what I am doing wrong, or (b) knows where I can get my hands on a mercury switch to try out....
or (c) if anyone has used the solid-state Omron or similar Tilt sensor devices. I really don' t need anything that fancy so I'd rather not steer into solid state.
thanks!
marshall
--
You received this message because you are subscribed to the Google Groups "NYCResistor:Microcontrollers" group.
To post to this group, send email to nycresistormi...@googlegroups.com.
To unsubscribe from this group, send email to nycresistormicrocon...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nycresistormicrocontrollers?hl=en.
http://www.sparkfun.com/tutorials/167
Or you could try the OSRAM optical switch but it's a leadless surface
mount part that would be a pain to solder, and I suspect it might have
similar noise/oscillation problems like the spring switch you've
already tried.
--
-Will
www.partsandcrafts.org
Since I've noticed that the "off" zone is much cleaner than the "on", so perhaps I could combine a few of these ideas - use 2 switches, but turn one around so I'm triggering from a combination of both an "off" signal AND an "on". Don't know how it will work yet, but it just might be the ticket.
m
That could definitely help, but if you want to play a bit with the
single switch and scaling the closed timing vs the open, as a previous
poster suggested, I can give you some example code I've used.
Basically it sets a short debounce time and a longer "safety window".
After the first "closed" passes the short debounce, it uses millis()
to keep track of the time, it will only register a second "closed"
after that safety window has passed. Pretty straightforward in its
most basic form, just adding a variable and an extra if... to the mix.
--Andy
Anyway thanks again!
m