im trying to get my project to read a value on A0 via a potentiometer. then take that reading and output it to a percentage.
my pot minimum reading is .46v but floats around .50v when circuit voltage (5v) is fully applied
my pot maximum reading is 4.62v but floats around 4.75v when circuit voltage (5v) is fully applied
i need to out put a percentage based on its position… so at .46v = 0% thru to 4.75v = 100%
i tried the map() function… it didnt work… my map() example code was
int pMin = .46;
int pMax = 4.75;
val = analogRead(A0); // reads A0 pin for data
percent = map(val, pMin, pMax, 0, 100.0);
When i fought it for hours and googled the snot out of it, i came up with nothing so i removed it entirely…attached is my original code without map() function… can someone help me out here?
Also, can the code be cleaned up to gain more memory?
sketch_may11a.ino (2.69 KB)