Vorpal Robotics Wiki
Log in

Scratch Example Hello World

From Vorpal Robotics Wiki

Vorpal Hexapod Quick Links:

Purpose

This is a very simple Scratch program that will make Vorpal "wave hello". It's a great way to get started.

Code

Scratch Hello World Program

What It Does

Explanation

  • WHEN GREEN FLAG CLICKED: This block means that the program will start running when the green flag button (upper right corner of the scratch screen) is clicked. It just gives you a simple way to start the program.
  • REPEAT 3: This is a control block that causes the blocks inside it to execute three times in a row. You could get the same effect by simply repeating the blocks three times, but that would be more time consuming, plus by using the repeat block you can easily change the number of times Vorpal waves.
  • SET LEGS (two blocks): These two blocks actually make Vorpal wave. The first SET LEGS block moves leg number zero (front left leg) so that the knee puts the leg up in the air, but also sets the hip back a little. This movement is held for 0.2 seconds, just a short time. The second block leaves the leg up in the air but moves the hip forward, again for 0.2 seconds. Don't worry about the meaning of "mirror hips" yet, we will get to that in more advanced programs.
  • STOP: The stop block at the end resets Vorpal to a standing position and shuts down any other activities that might have been happening at the end of the program. It's always a good idea to end every program with a STOP block.

Experimenting With This Program

Take a moment to play with this program to see how things change if you:

  • Modify the REPEAT count to make it higher or lower than 3
  • Change the knee or hip angles to get a feeling for how those numbers affect the position of leg 0.
  • Switch to leg 5 to wave with the "right hand" instead of the the left.
  • Add additional SET LEGS blocks to make the waving motion more complex.

Adding The Wave Motion To The Gamepad

In order to trigger this motion from the gamepad, we simply have to enclose the motion blocks in between RECORD START and RECORD END blocks like this:

Scratch Hello World Program, Gamepad Version

The RECORD START command causes the following code (up to the RECORD END block) to be saved to Dance mode 3 (D3 DPAD button) and triggered when the DPAD "special" button is pressed (that's the button up at the top of the DPAD). After you execute this code (by clicking the green flag and watching the robot repeat the dance move) you will be able to trigger this motion by:

  1. First, do a long-click on D3. That means you hold down D3 for more than half a second. You'll hear one tone as soon as you start pushing D3, then half a second later a higher pitched tone will confirm that you successfully entered long-click mode.
  2. Now just press and hold the DPAD "special" button, which is near the top of the gamepad, above the "V" logo. As long as you hold it, the waving motion will continue. This is because holding down the button will repeat the programmed leg motions over and over again.

You can get back to the normal D3 functions by doing a short click on the D3 button.

Next Example: Dance Party

Click on this link to go to the next example: Scratch Example Dance Party.

Vorpal The Hexapod Quick Links

Sign Up For Our NEWSLETTER VORPAL FORUM: Join the Discussion

User Documentation:

Getting & Giving Vorpal

Activities:

Contact/Press: