I have a circuit like this that has a 12vDC power supply. I would like to measure the voltage on either side of each of the lights with the arduino's analog input pins, but the arduino's max voltage is 5v.
How would I keep the voltage at least proportional to its value while making it less than 5v?
Normally to read voltage from the arduino, I would get the value, which is a number in between 0 and 1023, then multiply it by 5/1023 to give me a voltage between 0 and 5 volts. Could I just stick a resistor between the point on the circuit and the arduino, then multiply the value from the input by 12/1023?
Best Answer
To linearly reduce a higher voltage to a lower voltage requires a resistor potential divider like this: -
So if the bottom resistor is (say) 5 kohms and the top resistor is (say) 7 kohms then 12 volts in becomes 5 volts out but, you might want to give a little headroom so that 15 volts in becomes 5 volts out. so use a 5 kohm for Rbottom and a 10 kohm for Rtop.
I would also be tempted to put 100 nF across the lower resistor so that the ADC sampling operates accurately.