I would like to know.
I have Pin 2 and 3 as INPUT_PULLUP. I have switch to each other pin. Why when I press switch at PIN 2. SOMETIMES PIN 3 also getting input. Why?
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
Serial.begin(9600);
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?
