VCS Example Program - Modkit - V5 Clawbot - Opening and Closing the Claw

This example program shows how to program the V5 Clawbot to open and close its claw using Modkit.


  • A V5 Smart Motor, on Port 3, named ClawMotor.

How it works

First, the when (STARTED) block tells the robot to run this code when the program starts.

Then, the claw motor is set to spin in reverse. Since spin is used, the motor will begin rotating and the program will continue immediately. Spinning in reverse causes the claw motor to open the claw jaws.

Then the program will pause for two-tenths of a second ( .2 seconds) to allow the motor to start spinning.

Next, the program will enter a while loop, continuously checking if the motor's velocity is negative (< 0). When the claw jaws open fully, the motor's movement will be resisted. When this occurs, the velocity will become 0 and the loop will exit. Because the loop is empty, nothing else will happen while the claw is opening.

Then, when the claw has finished opening, the claw motor will be commanded to stop. This stops the motor's spin so it does not continue trying to open. When this happens, the claw jaws will spring back slightly.

Next, the program will pause for 1 second.

Finally, the spin block, while loop, and stop block are repeated, but spinning forward. Spinning the claw motor in the opposite direction will make the claw jaws close. When the claw's motion is resisted, the loop will finish and the motor will stop.