Programming Loops - Blocks-based
The V5 Clawbot is ready to move!
You can use the Help information inside of VEXcode V5 to learn about the blocks. For guidance in using the Help feature, see the Using Help tutorial.
Quantity | Materials Needed |
---|---|
1 |
VEX V5 Classroom Starter Kit (with up-to-date firmware) |
1 |
VEXcode V5 (latest version, Windows, MacOS, Chromebook) |
1 |
Engineering Notebook |
1 |
Using Loops (Tutorial) |
1 |
Repeating Actions (No Gyro) example project |
Step 1: Let's start programming with loops.
- Start by watching the Using Loops tutorial video.
-
Open the Repeating Actions (No Gyro) example project.
-
View the opened example project.
Do the following in your engineering notebook.
-
Predict what the project will have the Clawbot do. Explain more than the fact that the project repeats.
What is it repeating? What is the Clawbot doing?
- Write your prediction, but do not break the short project into more than two parts.
-
Save, download, and run the Repeating Actions (No Gyro) example project.
-
For help, see the tutorial in VEXcode V5 that explains how to Download and Run a Project.
- Check your explanations of the project in your engineering notebook and add notes to correct them as needed.
Step 2: Run the project and observe the robot.
Look at the Repeating Actions (No Gyro) project (on the right) again. This project will repeat the forward and then turn behavior four times. A repeat block is used when you want to use a set of behaviors for a certain number of times. If the repeat block is replaced with a forever block, the robot would repeat the forward and then turn behaviors forever.
In the project on the left, a sensor's input is used to determine when to begin turning. The project on the right uses a fixed Drivetrain distance to determine when to begin turning.
In order to continually check a sensor's input, an if/else block is used together with a forever block. In the project on left, the robot will turn right when the BumperH sensor is pressed, otherwise the robot will drive forward forever if the BumperH sensor is not pressed. To continually check the BumperH sensor's value, the if/then block is within a forever block.
The above project on the left is a practical use-case of a structure that repeats forever - using forever blocks and if/then blocks together. Imagine a self-driving sweeper that continues to drive forward until it runs into a wall or object, then turns before continuing to drive.
Step 3: The Squared Loops Challenge!
- Have your Clawbot drive in a square.
- Before each turn, the claw must be opened and closed, and the arm must be raised and lowered.
- The Clawbot cannot drive along a side of the square more than once.
- You can use the Repeating Actions (No Gyro) example project as a starting point but save it as SquaredLoops before making any changes.
In your engineering notebook, plan the following:
- Plan out your solution and predict what each block in your project will have the Clawbot do.
- Download and run your project to test it before submitting it.
- Make changes to the project as needed and take notes about what was changed during testing.