I have this tectile switch:
and I want to connect it to my arduino micro and get some print statement in my serial monitor when i press it in a certain direction.
I have 0 experience with electronics and I don't understand how to wire it up. I watched alot tutorials about buttons and leds but I could not find one about this switch.
It has 6 pins based on the datasheet pin1 is common so I have wired it to ground. The other pins I wired to pin 2-6 digital pins of the arduino. Then I tryed to read the output of the first pin but it was random either 0 or 1 and it never reacted to my clicks. This is my code:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(6,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int pin2 = digitalRead(2);
int pin3 = digitalRead(3);
int pin4 = digitalRead(4);
int pin5 = digitalRead(5);
int pin6 = digitalRead(6);
Serial.println(pin2 , DEC);
delay(80);
}