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?
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.
Really? 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?
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