Using car switch for Arduino input

I'm tinkering with my project car and I'd like to use one switch in the car that has no function, to trigger Arduino. It's a pushbutton switch, so I'd like to be sure how to correctly hook it up, especially regarding pullup resistors (internal, in the IDE) or external, not sure which approach is more technically correct?

Are any of the terminals of the switch in the car connected to anything and how many terminals does it have ?

Note that there is a possibility that at least one of them is connected to the car bodywork

For this experiment and project, I would remove both wires on the button and have that button work only with Arduino - no duino, no functionality. So whatever connection it may have with the car, it would be removed.

I already have a fuse block with 6 positive and 6 negative terminals for whatever tinkering electronics I plan to put in the car - can I use this as my ground? Arduino will be powered by a standalone DC converter, 5Vdc.

If you are absolutely certain that the switch is not connected to anything on the car then you can treat it like any other pushbutton switch connected to an Arduino

Connect one side of the switch to an Arduino pin and use INPUT_PULLUP in pinMode() to activate the internal pullup resistor to keep the pin in a known state. Connect the other side of the switch to GND so that the pin is taken to GND when closed. With that done digitalRead() will return a state of LOW when the switch is closed

It is worth noting that a car is a very hostile environment for electronic components of all kinds

1 Like

Thanks! It's an experiment vehicle so its primary purpose is to serve as my playground, rolling on the road is not on the priority list :smiley:

Is there any rules or best practices I should know when it comes to pullup? A lot of people use the 10K resistors for pulldown, but then again there are pullup internally available on most is there a purpose when to opt for internal vs. external resistors?

Use the internal pullups as I suggested. Simple to turn on, no external components to worry about. They just work

If for some reason you simply must use pulldown resistors then only very few Arduino boards have them built in. 10K seems to be the favoured value

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.