Arduino sensing motion somehow???

I made a video about the issue because I wouldn't know how to explain it in text. I'm new to electronics and this got me really excited. I'm very curious to know whats going on, any help would be much appreciated.

https://www.youtube.com/watch?v=JqDlhZboEpI

Floating input?

Not much to go on - post your code and a schematic.

Your input pin is (edit: probably) floating.

Rather than just use pinMode with INPUT, turn on the internal pullup resistor with INPUT_PULLUP and re wire so the switch goes to ground not 5V. Adjust the HIGH and LOW for the LED to match.

The logic reverses as a consequence of a pullup. Pullup ensures your input is always at a state you can trust: it’s HIGH when not pressed, and LOW when pressed. Right now it’s picking up who knows what from the atmosphere when it’s not pressed.

Hi, What appears to be happening is that when your button is not pressed, the input pin of the arduino is not connected to gnd or 5V. It is what is called floating, the input is high impedance and it does not take much electrical charge to get its potential high enough to represent a high input, in fact the anti-static bag that is under and around your controller is acting like an antenna and as you approach is probably charging up from you body.

The solution is to turn on the Pullup Resistors in the arduino, this will pull the input high when there is nothing connected to the pin. You then connect your switch between gnd and the pin, you will not damage anything switching the pin to gnd as the pullup resistor is relatively high in value.

This means your logic is reversed, press the button causes a low on the input pin.

The other solution is to leave your switch between the input pin and 5V, but also connect a 10K resistor from the input pin to gnd. This way your logic will not change, but when your button is not pressed the pin is pulled to gnd by the resistor.

Tom.... :)