Map() function

Constrain manually and use an if statement to separate the positive and negative direction, then map. Kind like:

if (pot > 507) {
  motor = pot;
}
else if (pot < 503) {
  motor = map (pot, 0, 503, 0, 507);
}
else {
  motor = 507;
}

It isn't very elegant but will do what you need. One single map statement can't deal with the plateau from 503 to 507.

Korman