From 3304b8f2efc280ed3c0f66499c8951b3640f1671 Mon Sep 17 00:00:00 2001 From: Jacob Quatier Date: Thu, 3 Jan 2019 16:05:25 -0800 Subject: [PATCH] constrain to values outside range --- servometer/servometer.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servometer/servometer.ino b/servometer/servometer.ino index 434db27..60af352 100644 --- a/servometer/servometer.ino +++ b/servometer/servometer.ino @@ -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); } /*