Accidental proximity sensor.

Ok,,, I have some weirdness going on.

After working on a little project that I can't quite get to run right I decided to dumb it down.

I just wanted to check my inputs so I loaded the "Basic Digital Read" example. Wired things up. But when I put in a jumper wire into the input pin (that is assigned) it then acts as some kind of antenae and the whole thing acts like a proximity sensor.

That is, if I get 8 to 6" from the antenae, the LED will turn on. the antenae, is only connected to the #7 pin. and not to ground or vcc (it is dangling)

what is going on?

It, unfortunately, is kind of flaky and I don't think it can be used in a positive or effective manner.

Is this some how detectinc capacitance? Or did I some how manage to fry something. I have tried other input pins too.

Any explanation would be greatly appreciated.


int ledPin = 13; // choose the pin for the LED int inPin = 7; // choose the input pin (for a pushbutton) int val = 0; // variable for reading the pin status

void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inPin, INPUT); // declare pushbutton as input }

void loop(){ val = digitalRead(inPin); // read input value if (val == HIGH) { // check if the input is HIGH (button released) digitalWrite(ledPin, LOW); // turn LED OFF } else { digitalWrite(ledPin, HIGH); // turn LED ON } }

I'm just guessing, but to me the following seems to happen here: You declared pin 7 as a digital input, and now it's floating. That means it's neither connected to HIGH nor to LOW (+5V or ground) and the Arduino doesn't quite know which state the pin is. That's why digital switches usually need to be connected to either HIGH or LOW with a pull-up or pull down resistor, do produce a defined state which the Arduino can detect.

seems about right.

Yes, I just had the one end floating, the other into my input.

I am wondering though, how this works. and if it could be used effectively.



Have you tried the AC input?

well. because the input is floating, voltage is changing all the time. and sometimes it's above trigger level, sometimes lower. the problem is that it could hapen while the atmel is doing other things, so the trigger is missed.

Actually is is quite unpredictible. sometimes the static in the air is so high that the arduino will sense high all the time, and sometimes its just to low to be of any use. industrial proximity sensors are sabelized and calibrated to a certain level of static, so they are predictible and therefor useful.