I would like to know.
I have Pin 6, 7, 8 and 9 as INPUT_PULLUP. I have switch to each other pin. Why when I press switch at PIN 6. SOMETIMES PIN 7 also getting input. Other case, also when I press switch at 7, other pin also trigger. Why?
This case is random. Sometimes everything is ok when I press 10 times, but after that other pin also trigger. Another case only 4-5 times press, then other pin also trigger.
I use switch on/off not temporary switch.
How to fix this? Is it common problem with arduino?
UPDATE
Program. (Simple Program)
int led1 = 1;
int led2 = 2;
int led3 = 3;
int led4 = 5;
int switch1 = 6;
int switch2 = 7;
int switch3 = 8;
int switch4 = 9;
int led = 13;
//int counter = 0;
void setup()
{
// put your setup code here, to run once
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(switch1, INPUT_PULLUP);
pinMode(switch2, INPUT_PULLUP);
pinMode(switch3, INPUT_PULLUP);
pinMode(switch4, INPUT_PULLUP);
pinMode(led, OUTPUT);
}
void loop()
{
if (digitalRead(switch1) == 0){
digitalWrite(led1, HIGH);
}
if (digitalRead(switch1) == 1){
digitalWrite(led1, LOW);
}
if (digitalRead(switch2) == 0){
digitalWrite(led2, HIGH);
}
if (digitalRead(switch2) == 1){
digitalWrite(led2, LOW);
}
if (digitalRead(switch3) == 0){
digitalWrite(led3, HIGH);
}
if (digitalRead(switch3) == 1){
digitalWrite(led3, LOW);
}
if (digitalRead(switch4) == 0){
digitalWrite(led4, HIGH);
}
if (digitalRead(switch4) == 1){
digitalWrite(led4, LOW);
}
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
}
Schematic
My Circuit is simple as like that for the input. For the output only to led, resistor and ground.
I found similar case http://www.instructables.com/id/Arduino-Push-Switch-Debouncing-Interrupts/
On the website, He said, "The problem with this setup was when the button was pressed the interrupt was being called multiple times and even toggling other buttons. Why was this happening? It is caused from a switch bouncing feedback."
Is there any solution without modifying the hardware?
SOLVE
The problem is the wire.
My wire for switch is jumper cable, and each other closer (touch) to each other cable. I try to separate, and works. There is no other pin will be trigger.