How to use bumper switch that has a long arm with Arduino?

There are lots of examples on using button switches with Arduino. A resistor is needed in each sample. How about bumper switch which has a long arm. Do I need to connect a resistor to this kind of switch? Are there sample program and sample wiring diagram on how to use long armed bumper switch with Arduino?

Assume you have not Googled "robotic bumper switch" There is a switch example in the IDE.

|500x449 .

It's just a button with an arm, so you wire and code it the same way.

Easiest though, is to use the built-in pull up resistors and pinMode(myPin, INPUT_PULLUP); so you don't need to mess around adding a resistor.

Afaik most such switches have both Normally Open and Normally Closed (NO, NC) connectors so be sure to wire the one you need; the other wire goes on the Common connector.

Thank you. I was using pinMode(myPin, INPUT); and got strange behavior.

Do all these "button with an arm" switches have a built-in resistor inside? I saw a photo of somebody soldering a resistor to the ends of the resistor.

pinMode(myPin, INPUT_PULLUP); // turn on internal pullup resistor

newto_arduino: Do all these "button with an arm" switches have a built-in resistor inside?

I doubt it, but to be sure you would need to check the datasheet of the actual one to hand.

But easy enough to check with your ohm meter. With the switch in normal position, ie un-pressed, between Com and NC you should get 0 ohms (they are connected) and between Com and NO, an open circuit. Then with it pressed, you should get an open circuit between Com and NC with 0 ohms on the Com / NO side.

Thank you all for your help.

As a matter of interest, do you have a multimeter? If not it should be at the top of your birthday list :)