Using Vin pin in Arduino Code

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.