I have Pin 26, 7, 8 and 39 as INPUT_PULLUP. I have switch to each other pin. Why when I press switch at PIN 26. SOMETIMES PIN 37 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?
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);
}

