The drivetrain gives your robotic invention the ability to move. Drivetrains come in different forms. In this example, we will use the Clawbot IQ robot base design, consisting of a rectangular chassis, two motors, four wheels, and gears that transmit power from the motors to the wheels. In this tutorial, you'll learn about the drivetrain and program it to drive forward and turn. You'll also use setup blocks to set the turn and drive speeds.
- VEX IQ brain
- Fully assembled VEX IQ drivetrain (omni-wheels optional)
Let's create a program that moves the drivetrain forward, turns it 180 degrees, stops it, then repeats the steps continuously.
Open the Modkit for VEX editor. Drag a drivetrain onto the screen and assign the same ports as you will on the physical drivetrain. In this example, the left rear is assigned to PORT 1 and the right rear is assigned to PORT 6.
Next, click on the 'Blocks' tab, and make sure that you are editing the drivetrain. Drag a ‘when START’ block onto the screen. The 'when START' block runs once each time your program runs. Drag a 'forever' block underneath the 'when' block. This block runs continuously, allowing your robotic invention to change and respond as it runs.
Next, drag a 'drive FWD 25mm' block and set the distance to 100mm. Drag a 'turn LEFT 45 deg' block and set the angle to 180 degrees. Lastly, drag a stop block onto the screen. This program will move the drivetrain forward 100mm, turn 180 degrees, stop, and repeat the steps continuously.
Download your code, and run it on the physical VEX IQ brain. Note that the turn may not be a perfect 180 degrees due to friction. Look up turning scrub to learn more.
Next, let's modify the program to control the turning speed and drive speed. Place the turn and drive speed setup blocks underneath the 'when START' block and outside of the forever block. This location ensures that the setup blocks are run only once each time your program runs. Set the values of the turn and drive speed to 20%.
Download your code, and run it on the physical VEX IQ brain. Observe how the drivetrain turns slower and drives slower than before, because of the setup blocks.
In this tutorial, you learned about the drivetrain and programmed it to drive forward and turn. There is so much more that you can do! Check out our other Getting Started guides.