I am currently building an arduino game controller that uses 2 joysticks and 2 cherry mechanical keyboard switches(tactile). I am using both of these 2 switches for the triggers as they feel much nicer than the tactile buttons. However I dunno why but when 'read' from the switches they regularly actuate even if I am not pressing them:
Snippet of code:
void loop{
if (digitalRead(16) == HIGH){Serial.print("HIGH ");Serial.println(counter); }Serial.println("---------");counter += 1;delay(100);
}
SERIAL MONITOR READOUT When switch is untouched(should all be blank in theory):
HIGH 97
HIGH 98
HIGH 100
HIGH 101
HIGH 103
HIGH 104
HIGH 106
HIGH 107
HIGH 109
HIGH 110
HIGH 112
As you can see there is a pattern where it reads 2 values before blanking for 200ms before skipping 2 then re-reading it
When pressed the HIGH is lines up perfectly (HIGH 119,120,121, etc.)
I have tried to change the code a few times to retake the readings after 10ms but I come to the same problem again where it seems to work but then has a specific amount of false readings before returning to normal. I have tried searching up "debouncing" but I am not sure if this is even bouncing?
When I apply their fixes the inputs are either non-existent or it doesn't work
Does someone know what this is caused by and how to fix it?
