Input pin wired to 12V negative switch when using DC-DC step down

Hi, I am working on a Arduino project for my motorcycle. I want to be able to check if a switch located inside the engine is on or off. Will it work to wire it up as shown below, and use analogRead() with INPUT_PULLUP on the Arduino to determine if the switch is open or closed?

Since the switch is on the 12V part of the circuit, do i need a resistor / voltage divider between the Arduino and the switch, or will this just work because the Arduino is powered through the DC-DC step down?

I am using an Arduino Nano, and this is the DC-DC step down I have planned to use: 5PCS Ultra-Small Size DC-DC Step Down Power Supply Module 3A for Arduino | eBay

Since I am new to the forum I could only post one image, here a image of the DC-DC step down:

Going by the circuit diagram, the switch is on the ground line. So the pull-up will make the pin read ‘high’ when the switch is off and ‘low’ when the switch is on.

The switch is nowhere near the 12V rail (according to the diagram) so you have no risk of frying the Arduino.

If the 12V is indeed going to be directed towards the input pin, you could always run it through another step down converter, 5v regulator, or switch through a transistor.

Thanks a lot, for your reply!!!! This sounds promising, just what I hoped for. Since my electronics knowledge is limited I thought it was best to check it :grin:

1 Like

No problems at all. :slight_smile:

I edited my last post but you got in before me.

“ If the 12V is indeed going to be directed towards the input pin, you could always run it through another step down converter, 5v regulator, or switch through a transistor.”

Good idea, and good to know :+1:

1 Like

If in doubt, just pop back with any additional updates. Nothing worse than frying things when you are in the middle of a project. :smiley:

1 Like

Thanks again, I will test it quite soon. This is just a small part of an Open Source project I have initiated: GitHub - KIHestad/Ctrl-MC: Arduino Motorcycle Controller Software

1 Like

Nice one.

Just double check with a multimeter that you aren’t going to get 12v anywhere near that input pin when you toggle the switch.

Yes! will do :face_with_monocle:

1 Like

Common mistake.
You connect the 5V from your DC-DC converter to the 5V pin, not Vin of the Arduino.
Vin is the input of the onboard 5V regulator applying 5V there will guarantee less than 5V on the regulator output.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

Really? :hushed: That was news to me! I though it was for voltage input (pretty sure I have seen it used on multiple tutorials - but of course, you cannot trust whatever you see on the Internet....), and the 5V pin was for sharing the voltage to other units, breakout boards and stuff...

When should the VIN be used? If you power from a source above 5V? Ex if you have a 9V battery?

On many Arduinos including the Nano, Vin needs a voltage of 7V or more. It will even take 12V. But the 5V DC-DC converter is a good way to go.


1 Like

Please supply a link to a few of these so they can be corrected. It could be however that you misunderstood what you were looking at.

1 Like

Thank you very much for the clarification. This was very useful input for me. This forum and the help I get here is just fantastic!!!

It could absolutely be me having misunderstood the tutorials, this might be just common knowledge that most take for granted. I have just never heard any explained this in any tutorial, and I have seen a lot of them lately since I am quite new to the game :relieved:

If you are powering the Arduino via the 5v pin (unless you know it’s safe) always disconnect the external 5v power from the 5v pin when the Arduino is connected to the USB cable.

1 Like