Skip to content

Commit

Permalink
constrain to values outside range
Browse files Browse the repository at this point in the history
  • Loading branch information
jquatier authored Jan 4, 2019
1 parent db0ab43 commit 3304b8f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion servometer/servometer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ String getValueFromResponse(String data, char separator, int index)
*/
int findServoAngle(String value)
{
return (180 - map(value.toInt(), 0, 2000, SERVO_MIN, SERVO_MAX));
return constrain((180 - map(value.toInt(), 0, 2000, SERVO_MIN, SERVO_MAX)), SERVO_MIN, SERVO_MAX);
}

/*
Expand Down

0 comments on commit 3304b8f

Please sign in to comment.