Go Down

Topic: Using Vin pin in Arduino Code (Read 127 times) previous topic - next topic

andgu32

New user to Arduino IDE here and I was just wondering if there is a way to access the Vin pin when writing code in the IDE. For context my project uses the A0 pin on my Uno to display the battery percentage on an LCD. I was hoping to change the A0 pin to the Vin pin but I do not know how to define the Vin pin in the code.

For the A0 pin I just use  :  int battPin = A0;

Is there a way to do this with Vin? I tried to look this up but all I could get was information about how and why people use the Vin pin.

Thank you in advance for any information you can provide.

pylon

Quote
Is there a way to do this with Vin? I tried to look this up but all I could get was information about how and why people use the Vin pin.
No.

The Vin pin is connected to the high voltage side of the voltage regulator on the Arduino board. You cannot access it from the processor.

Datman

You have to do a voltage divider using two resistors, so that the resulting voltage is lower than 5V in all conditions, then connect the resulting voltage to an analog in.
Hi, I am Gianluca from Roma. I play and work with electronics since I was 16 (1984).
After 25 years of maintenance on cameras and video mixers, since 2013 my job is HD TV studios design.
In Jan 2015 I began playing with Arduino.

Go Up