Greetings,
I started playing around with a few sensors I've harvested from an old printer.
When I tested some switches, I've noticed, that the input values of the arduino pins are never 0.
Even when I have no electronics what so ever on the pins, the state of the pins seem to be random.
Digital as well as analog inputs.
Here is my example code:
void setup() {
Serial.begin(9600);
pinMode(1, INPUT);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);}
void loop() {
Serial.print("Pin 1: ");
Serial.println(digitalRead(1));
Serial.print("Pin 2: ");
Serial.println(digitalRead(2));
Serial.print("Pin 3: ");
Serial.println(digitalRead(3));
Serial.print("Pin 4: ");
Serial.println(digitalRead(4));
Serial.print("Pin 5: ");
Serial.println(digitalRead(5));delay(100);
}
If I use a button and press it, I always get the state 1. But elsewise the state is either 1 or 0, switching randomly.
Am I doing something wrong? Is my Arduino Uno somewhat broken? (It's about 3 years old)