Asked — Edited

Making A Servo Stop

I'm perplexed....:) is there a simple script command that can stop a servos movement when the servo starts moving?

I am trying to use a lever switch within a gripper. When I tell the gripper to begin closing around an object, and then the object presses against the lever switch,the gripper servo could immediately stop.

I've looked thru the EZ script manual, just cant the right command or function. Any ideas? Thanks in advance.


Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential!


you can set the gripper ,degree you want him to stop

setservo(d8,90) stop()

ecample servo wil stop at 90 degree


@RoboHappy, How is your Lever switch connected to the v4?


Not sure what nomad is talking about, but a servo will move or attempt to move to the position it was told to... the only way to stop it is the physically block it or hold it from moving which could damage it... You can use the command release to basically kill power to the servo...

release(D0) #releases the servo from port D0

In order to use a lever switch you will need to read it on another digital port... It will need a pull up resistor.... Once the switch is triggered the pin will go high (or low, depending on how you wired it).... You can read this and then use the command release to kill the servo movement....


I think robohappy is assuming servos have some sort of feedback mechanism. As i had mentioned in the other post regarding speech recognition (Where i made the video), servos are motors. Servos move into the position that you request. They will force with all their might to move into the requested position. You can find out more about servos using the LEARN section. Here is a direct link to the servo lesson in your JD robot:

It's a good read that will give you insight on how a robot works. When you opened the JD box, loaded the software, and followed the instructions, there are warnings not to exceed servo limits. If you do, a servo will be damaged.

If you'd like your robot to hold stuff. Add foam pieces to it. Here, i'll show you what i have done..

I should also add that I got the soft foam from the newer ezrobot robot box. The newer boxes have a soft foam compared to the old hard foam. I had the foam changed once I found out how bad dense foam is for the environment. Soft foam is much better for the environment, but still not great... But better! And it makes good gripper holders.


If you use a continuous rotation servo, you could just tell it to move the needed direction and put a stop when the adc value of that lever switch hits the value which means closed on an object. With a standard servo, it's almost impossible unless you add feedback and track how far it has moved and when it is triggered, set the position to the value that was being output by the feedback potemeter at the time.


Thanks guys, I am still reading and searching some stuff. This idea steamed from a recent book about building a Arlo robot from John Blankenship.

Yes I am using a lever switch connected as an input, which ezb reads it just fine. I do want to mount into the gripper,and have the object press the switch and cause the grippers moving servo stop all together as to not break the servo or the gripper. I would also be using some foam rubber to help with the grip. I do know servos dont have feedback, and I use all kinds of servos in all my Rc model airplanes for years. I like the "release" command idea, but will that stop the servos motion or actually cause the servo to be inactive?

Im using the ezb gripper for this design, and later I may plan on changing over to Vex hardware for the arms.


As mentioned, be careful about using a rubber instead of foam. Foam is much softer and healthier for the servos. I mentioned that in my previous post for reference.

The servos to do not "stop" while closing. You will need to send each position, reading the switch on sending each position.


You could do this(unchecked and untested FYI):

 $servoposition = 20 #Minumum servo value for the gripper goes here
Servo(d7, $servoposition)

If (getadc() = 26)#closed adc value
Servo(d7, $servoposition + 1)#change this number for increments to go up.
Else (say("Gripper closed")


this is the script, assuming the pressure sensor is a digital switch. Otherwise use an ADC comparison like Techno had demonstrating

REPEAT ($position, 40, 90, 4)

  # Move the servo into the position
  servo(d11, $position)

  # Check if the pressure sensor has been tripped
  IF (getdigital(d18) = true)

    # Stop the script because pressure sensor has been tripped




Thank you again guys. I tried yours DJ,did several test and it worked pretty good. I will plan on using it with my next arm configuration.


I made a gripper using a rotating servo and 2 limit switches. The way it works is like this. Gripper opens fully and hits the open limit. When closing, it Closes until the inner switch get pushed in. And like DJ I also have foam in the gripper. The foam has to be compressed a Little to trigger the switch, this gives a good grip.


@glycol79..>Nice, at one time I though about doing something like that. Right now, im the process of mounting the whole arm assembly to the bot. Would like to upload a pic of it whe I get the chance too.