I am trying to get the Arduino Uno board to control a gripper driven by a servo motor. The servo tries to go beneath 134° which is mechanically impossible. What can I do to fix this?
I tried to limit the motor to 180°, when it was not a reading of wanted buttons it would keep main position (closed, 180)
#include <Servo.h>
Servo myservo;
char reading;
int pos;
void setup() {
// put your setup code here, to run once:
myservo.attach(9);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
reading = Serial.read();
Serial.print(reading);
if (reading == 'W' || reading == 'w') {
pos = 134;
myservo.write(pos);
Serial.println("Open");
}
else if (reading == 'C' || reading == 'c') {
pos = 180;
myservo.write(pos);
Serial.println("Close");
}
else if (reading != 'W' || reading != 'C') {
myservo.write(180);
}
}
}