# convert 5v reading to 12v equivilant / analog input

OK so i am making a small variable power supply , 12v max , to use with my breadboards.
as well as an LCD (16 X 2 characters) to display how much voltage i am using at the moment.

i know i can only use my A.inputs with a max of 5v and translate the reading into voltage

``````  int  temp ;
float val ;
val =(float)temp * .0049 ;
``````

But my power supply is going to be 12v not 5v , so with some research i figured i could make a voltage divider where i have a max of 12v i will get a 5v output to use on my analog input reading, now being that this 5v will be an equivalent to the 12v how do i convert my 5v reading up to 12v?

i am assuming it is not as simple as mapping my reading AFTER the conversion i posted above..map (newTemp, 0 ,5 , 0 , 12) ?

If you want an accurate voltage divider you could use a trim-pot of, say, 5 kOhms. Put a measured 12v across the two ends and measure from ground to the wiper terminal. Adjust until the output is 5v.

The alternative is to use math where the sum of two resistors is about 5K and one of the resistors is 5/12 the value of the sum. 5/125k 2083 Ohma
and 7/12
5K = 2916 Ohms. Of course you can't order resistors with that precision. The closest you can get in 1% resistors are 2.10K and 2.94K and each of those might be off up to 1%.

A very accurate method that I've found is to use a multimeter to measure the voltage divider to get an axact ratio
then just multiply in software
Then check your reading against the multimeter to double check accuracy
also check what the 5v rail on the arduino is to get a more axact reading, like 5.15 versus just 5
I did this for my car and my arduino is now as accurate as my multimeter

Ex
analogread(a0); //dummy read just to make sure its clear
``````val = val / 5;   //adjust to be more exact