Tilt Sensor Help

Hi, i am trying to figure out how to properly use a tilt sensor like this one http://www.sparkfun.com/products/10289 i have been trying to use debounce code with the arduino, but the output continues to flicker. this is a problem as my ultimate goal it to have the tilt sensor activate a set of LED's that will gradually get brighter over a few seconds. and if the output continues to flicker then the led state will just turn on and off. any help is much appreciated, thanks

Assuming you are using the code from the debounce tutorial http://arduino.cc/en/Tutorial/Debounce

Did you try increasing the debounce delay variable? Try doubling it and test again...

long debounceDelay = 50;    // the debounce time; increase if the output flickers

Beyond that it would help if you could post your code.

willnue

I am using the "stock" code from the debounce coding. all i have changed is the that exact value you just posted. but i still get flickering values. any chance it may because of the tilt sensor having conductivity issues with the breadboard?

Tilt switches are usually very sensitive to the ball jiggling around inside the can. In that respect it's a little different from a pushbutton. Imagine when the object with the tilt switch attached is in motion it's the same as someone continuously hitting a pushbutton switch.

Try turning it upside down (end without wires facing down) and fix it to something so you aren't touching it. While it is in this position the circuit should be open and you should get a LOW reading from the Arduino. Now stand it right side up (end without wires facing up) and fix it so you aren’t touching it. Now the circuit should be closed and you should get a HIGH reading. Both of these should be steady either HIGH/LOW. Now experiment by moving it around and the flicker will return.

To get rid of the flickering you need to increase the delay to smooth over the "button pushes" the ball is making while it is moving around in the can. So, just try adding more delay!

willnue