I need close the circuit touching two wires, so, I take to print what was read, via Serial.println(), the problem is, it's reading wrong (prints 1 and 0 in different positions), I don't know what do, check the images. After I touch both wires, so it shows only 0. Below there is the code:
int pedal = 6;
int led = 13;
int pedalInput = 0;
void setup() {
Serial.begin(9600);
pinMode(pedal, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
pedalInput = digitalRead(pedal);
if(pedalInput == HIGH) {
Serial.println("1");
digitalWrite(led, HIGH);
} else {
Serial.println("0");
digitalWrite(led, LOW);
}
}
What can I do to fix this problem?
Thanks so much!!!