EasyC v4 - 4.0.2.7 Programming

Using EasyC block programming can a servo be set to be home at 127 and move to -127 with a digital input? We are trying to get the full range of movement from a servo with a single input, instead of home being in the middle of the range where two buttons are required to accomplish this.

You just SetServo(-127) and SetServo(127);

Though it should be noted when power is applied the servo will always default to home.

if (digitalinput)
SetServo(-127)
else
SetServo(127)

Thanks to you, kingofl337 we have it working beautifully. After operating the machine we decided it would also be advantageous at times to move to the servo to the middle or 0 position using a second digital input. We added another else statement to set servo at 0 from the second input and it works but we have a jittery motion with the new input and a smooth motion on the original. We have something wrong. Any ideas?

I don’t have a copy of your code, but I’d guess to say you have to statements that are conflicting and you are setting the servo values multiple times in the same loop.

Something like:

if (button == 1){
SetServo(1, 0);
} else {
SetServo(1, 255);
}
SetServo(1,127); //This is the servo #1 being set again (bad)

You’re exactly right. So now we’ve been trying to write code with two while loops controlling a single servo where assigned digital input to one loop takes priority or cancels the second loop and vice versa. We haven’t had any success yet. Is this the wrong way to get the results we looking for? Again, one controller digital button moves a servo from -127 to 0 and another moves the same servo from -127 to 127. Thank you for your replies.

Why don’t you just use three buttons? 127,0,-127?

Using code we are holding a servo continuously at -127 so that an attached claw remains closed without operator input, (less possibility of operator error). Then we want one button to open the claw partially (0) and another button to open the claw fully (127). It sounds simple but for newbies to programming it’s proving to be problematic.

You don’t have to keep sending the SetServo command. Just call it an forget about it, the Cortex will continue with that command until instructed to change.