I'm trying to proportion potentiometer value to analog pin value. Like 1024 to 255.
int readVolumePot() {
int val = analogRead(potVolumePIN);
Serial.print("VOL");
Serial.println((val * 255/1024));
return (val * 255/1024);
}
As potentiometer turns I got irrelevant values.
VOL3
VOL3
VOL3
VOL17
VOL-16
VOL-16
VOL-21
VOL-1
VOL-10
VOL-3
VOL-4
VOL11
VOL8
VOL13
VOL17
VOL15
In Arduino's website they say
some constant calculations may overflow (e.g. 60 * 1000 will yield a negative result).
Notwithstanding, I cannot find an appropriate way to convert the potentiometer value to analog pin value.
map().