I'm building a custom MIDI controller box with 6 faders/potentiometers for a client...
Here's my simple code for a 10k ohm linear potentiometer:
int cc = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
int sensorValue = analogRead(A0);
cc = sensorValue / 8;
Serial.println(cc);
delay(500);
}
So with MIDI CC values it goes from 0 to 127
However, viewing the serial monitor, the potentiometer reaches it's max value (127) before it should (see pic):
Linear or log potentiometers? Are you sure the pot isn't connected to a higher voltage than the Arduino? The calculation looks fine but put in a print of sensorValue too so you know exactly what you're dealing with.