Driving Basics - Drive and Rotate Blocks

It's been fun up to this point, but I bet you're ready to see the S3 move! The simplest way to get your S3 rolling is by using the drive block. It is located under the ACTIONS > MOTORS category and looks like this:

In this one block, you can control many important aspects of the S3’s movement using each of its three drop-down menus - forward, straight, and full in the image above.  By clicking on each menu, the various options appear allowing you to select the one you need.

The first menu allows you to set drive direction: forward or backward.

The second menu lets you choose to travel straight or in a curved path - turning slightly to the left or right, gently to the left or right, or sharply to the left or right.

Drive block with directional dropdown open to show options.

The third menu allows you select the speed at which you want your S3 to move full (100%), quick (75%), gentle (50%), or slow (25%). These speeds are based on an approximate percentage of S3’s maximum speed, which can differ based on the slope and texture of your driving surface.

Give it a try!

  • Set your drive block as above - to drive forward going straight at full speed.
  • Now run the program (and be ready to catch your S3).

Do you see a problem? Your S3 continues to move forward and straight at full speed with no end in sight. You need a way to stop!


Did You Know?

The S3 robot uses a differential drive system. This means that there are two drive wheels, each with its own motor, allowing them to move independently at different speeds and directions. On the S3 robot the drive wheels are located on the midline of the robot’s chassis and there is an unpowered tail wheel at rear. As you progress through these tutorials, you will come to appreciate this highly maneuverable design.

  1. When the drive wheels move forward at the same speed - the S3 drives straight forward (reverse the drive and the robot goes straight backward.)
  2. When the wheels turn at equal speed in opposite directions the robot spins in place - clockwise or counterclockwise. In this case the specially-shaped tail wheel slides across the drive surface, providing little to no friction for the sideways movement.
  3. Finally, when the wheels move the same direction, but at different speeds - the robot will travel in a curved path or arc.

Understanding these concepts will help you program your S3's movement properly. If this is difficult to visualize in your head, try drawing it out on paper. Use arrows to show which direction each wheel will go in each of the 3 situations we listed here.


 

The "Stop Driving Block" to the Rescue

You will find the stop driving block under the same categories where you found the drive block.

  • Add it to your program. It should look like this:

Drive program using the stop driving block.

  • Now run this version.

Your S3 stopped, because it didn’t drive anywhere, correct? This is because just milliseconds after the S3 received its drive command, it was given the stop driving command. To make the robot do what you want, you still need one more block - the wait block.  

The wait block can be found in the CONTROL category:

The default unit of this block is in millisecond(s). Value can be set by changing the number in the inner purple value block.

 

Try This

  • Create a new program in BlocklyProp that looks like the one below. Then run it on your S3.

It works! Now let’s try something new.

  • Write a program that looks like the following, and then run it.

To do this in another way, let’s learn about one more block - the rotate block. You will find it in the ACTIONS > MOTORS category. It looks like this:

The rotate block has settings for the spin direction (clockwise or counterclockwise - sometimes called anti-clockwise), the number of degrees to turn, and the speed of rotation (full, a quick, a gentle, or a slow speed). The degrees to turn menu drops down a neat tool allowing you to easily set your desired degrees (or you can type in any number between 1 and 359). See below where it has been set to 90 degrees:

Now, try this by writing a program that drives forward and back with a bit more style. You should have something that looks like this:

  • Run your program. Did it work as shown in the gif image below?

 

Your Turn

In the program above, as the robot reaches the rotate block, the S3 stops so quickly from full speed that you will hear the tail wheel chatter up and down.

  • Try rewriting the program above, changing settings or adding blocks to help eliminate that abrupt stop and turn.

What did you change? Did it work? Try different ideas until that chatter disappears. What did you learn?

  • Make a program that drives forward at full speed, spins 180 degrees and returns at a slower speed, traveling for a longer time, and yet returns to the same starting point. What slower speed did you use? What wait time did you use?
  • Write a program that drives forward, traveling sharply to the right at a gentle speed, and then stops. How long should the program wait before using the stop driving block if you want the S3 to travel for a full circle?

Special thanks to Parallax friend Whit Stodghill for his assistance in writing, editing, and testing material for these S3 tutorials.