Left and Right Turns
All it takes to get other motions out of your cyber:bot are different value combinations in the v parameters in your Pin18 and Pin19 calls to servo speed (v).
Rotating in Place
These two blocks will make your cyber:bot rotate in place to make a left turn:
These two blocks will make your cyber:bot rotate in place for a right turn:
The turns above can be called rotation turns because the wheel speeds are equal, but the velocity is opposite to make the cyber:bot turn about its center. This rotation is great for making the robot face a new direction in a tight place and without changing its position. Imagine a pen going through the center of the cyber:bot’s “axle.” A rotating turn would not draw any curved lines; it would just rotate on this point making the dot darker! You could think of this as an arc with a radius of zero.
Let’s combine these two commands with a forward and backward command into a single project that makes the cyber:bot move forward, turn left, turn right, then move backward.
Save Time of Adding the cyber:bot Extension to a Project
If you add the cyber:bot extension to a project and name it template, then duplicate it and rename it for new projects you’ll be able to use the cyber:bot blocks. This will save you the time of adding the cyber:bot extension to each new project.
Example project: forward_left_right_backward
- Set the PWR switch to 0.
- Set the project’s name to forward_left_right_backward, enter the blocks and arguments below, and then click Download.
PRO TIP: To create this project quickly, Duplicate the blocks to make four copies of the 3 blocks that make up a maneuver. Then, modify each one with individual values.
- Click Download to flash the project into it.
- Set the PWR switch to 2.
- Verify that the cyber:bot goes forward for 2 seconds, left for 0.6 seconds, right for 0.6 seconds, and backward for 2 seconds.
- Remember, to repeat the maneuvers, press and release the micro:bit module’s Reset button. It’s under the micro:bit next to its USB connector.
Pivot Turns
Another option for turning is by pivoting, where one wheel turns forward or backward while the other stays still. Now the center of the circle is the wheel that is not moving, and the cyber:bot pivots about this point. An imaginary pen through the center of the robot would draw a circle with a radius equal to about half of the cyber:bot robot’s wheelbase. The animation below shows a right-wheel forward pivot.
Here are the four routines for forward and backward pivot turns:
Pivot forward-left
Pivot forward-right
Pivot backward-left
Pivot backward-right
Try This: pivot_tests project
- Create a new project and name it pivot_tests.
- Change the v parameter value in each servo speed call so the project will perform all four pivot maneuvers: forward-left, forward-right, backward-left, and backward-right.
- Flash the modified project with Download and verify that the different pivot actions work.
- Try experimenting with the pause calls for each maneuver so that each one runs long enough to execute a 90° turn.
Your Turn: Arcs
So far, our turns have had either one or both servos turning full speed, or not moving at all. What happens when the servos turn at unequal velocities, but neither one is at full speed or stopped? The answer is, the cyber:bot will drive in an arc.
Arcs can be tight, where one wheel turns backward while the other turns forward, but at unequal speeds.
Arcs can be wide, where both wheels turn in the same direction, but at unequal speeds:
- Try making and test-driving a project to make your cyber:bot drive in a tight arc.
- Try making and test-driving a project to make your cyber:bot drive in a wide arc.