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.
code
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
}
}