Programming Turning Right and Left - Blocks-based
Teacher Toolbox - Activity Outline
-
This exploration will introduce students to basic turning right, left, and waiting programming behaviors.
-
Using the drivetrain robot configuration enables the students to program the Speedbot to turn by just selecting the [Turn for] block.
Speedbot is ready to turn!
This exploration will give you the tools to be able to start creating some cool projects for your Speedbot to follow.
- VEXcode V5 that will be used in this exploration:
- To find out more information about the block, open the Help and then select the [Turn for] block.
- Make sure you have the hardware required, your engineering notebook, and VEXcode V5 downloaded and ready.
Teacher Tips
If this is the student’s first time using VEXcode V5, they can reference the Tutorials at any time during this exploration. The Tutorials are located in the toolbar.
Quantity | Materials Needed |
---|---|
1 |
Speedbot Robot |
1 |
Charged Robot Battery |
1 |
VEXcode V5 |
1 |
USB Cable (if using a computer) |
1 |
Engineering Notebook |
Teacher Tips
-
Model each of the steps for checking that the Speedbot is ready so that students will get into the habit of doing so.
Step 1: Preparing for the Exploration
Before you begin the activity, do you have each of these items ready? Check each of the following:
- Are the smart cables fully inserted into all of the motors?
- Is the Brain turned on?
- Is the battery charged?
Step 2: Start a New Project
Before you begin your project, select the Speedbot (Drivetrain 2-motors, No Gyro) - Template project. The template project contains the Speedbot's motor configuration. If the template is not used, your robot will not run the project correctly.
Complete the following steps to open the template project:
- Open the File menu.
- Select Open Examples.
- Select and open the Speedbot (Drivetrain 2-motors, No Gyro) template project.
- Since we will be using the [Turn for] block, rename your project Turn.
- Save your project.
-
Check to make sure the project name Turn is now in the window in the center of the toolbar.
Teacher Toolbox - Saving Projects
Point out that when they first opened VEXcode V5, the window was labeled VEXcode Project and it was not saved (indicated on the toolbar). VEXcode Project is the default project name when VEXcode V5 is first opened. Once the project is renamed Turn and saved, the display updates to Saved. Using this window in the toolbar, it is easy to check that the students are using the correct project and it is saved. Once a project is initially saved, VEXcode V5 autosaves any subsequent changes, as indicated by the message next to the project name.
Tell the students that they are now ready to begin their first project. Explain to the students that by following a few simple steps, they will be able to create and run a project that will turn the Speedbot.
Teacher Tips
-
Since this is a beginning activity with programming, the teacher should model the steps, and then ask the students to complete the same actions. The teacher should then monitor the students to ensure that they are following the steps correctly.
-
Make sure that the students have selected Open Examples from the File menu.
-
Make sure that the students have selected the Speedbot (Drivetrain 2-motors, No Gyro) template project.
You can point out to the students that there are several selections to pick from on the Examples page. As they build and use other robots, they will have a chance to use different templates.
-
You can ask students to add their initials or the name of their group to the project name. This will help differentiate the projects if you ask the students to submit them.
Step 3: Turn Right
- Add the [Turn for] block to the {When started} block in the programming area.
- Click on the Slot icon. You can download your project to one of the four available slots in the Robot Brain. Click on the number 1.
- Connect the robot to your computer or tablet. The Brain icon in the toolbar turns green once a successful connection has been made.
- Click the Download button on the toolbar to download the Turn project to the Robot Brain.
Teacher Toolbox - Help with Blocks
-
Point out that in the programming area, there is already a {When started} block located there by default. Every project will begin with this block. When the project is started the connected blocks will be followed in the sequence in which they are placed.
Demonstrate clicking on the [Turn for] block and dragging it to the programming area, connecting it to the {When started} block. You will hear a click when as it attaches.
-
If you are using a computer, the student should have VEX V5 Robot Brain connected to the computer using a USB cable. If you are using a tablet, the VEX V5 Robot Brain should be connected to the tablet using the Smart Radio.
-
If the students are using a computer, ask them now to disconnect the USB cable from the Robot Brain. Having the robot connected to a computer while running a project could cause the robot to pull on the connection cable.
Teacher Toolbox - Stop and Discuss
This is a good point to pause and have the student reflect on running their first project. As students:
-
What did Speedbot do when you ran the project?
-
Did it behave as you would expect it to, based on the project?
Take a moment to make sure all students have completed this step without any issues before moving on.
- Check to make sure your project has downloaded to the Speedbot's Brain by looking at the Robot Brain’s screen. The project name should be listed in slot 1.
Teacher Toolbox - Model First
Model running the project in front of the class before having all the students try at once. Gather the students in one area and leave enough room for the Speedbot to move if it is placed on the floor. Since the Speedbot will continue running the project until the back button on the Robot Brain is pressed, the teacher may want to choose someone to assist in stopping the Speedbot's project when it finishes.
Tell the students it is now their turn to run their project. Make sure that they have a clear path and that no Speedbots will run into each other.
- Run the project on the Speedbot robot by making sure the project is selected and then press the Run button.
Step 4: Turn Left
Teacher Toolbox - Completing Step 4
-
To change the [Turn for] block from right to left, simply click on the dropdown menu and select left.
-
If the students are using a computer, remind them to disconnect the USB cable from Robot Brain before running the project.
Because we are not selecting a new slot, the new project will download to slot 1 and replace the previous project.
-
Since VEXcode V5 has autosave, there is no need to save the project again.
Step 5: Wait, then Turn Left
- Add a [Wait] block before the [Turn for] block. This will tell the robot to wait before turning left.
- Insert three seconds into the [Wait] block. This tells the robot to wait three before turning.
- Download the project.
- Run the project on the Speedbot robot by making sure the project is selected and then press the Run button.
Teacher Toolbox - Completing Step 5
-
A [Wait] block can be placed anywhere in the project. For more information on the [Wait] block, open the Help.
-
Using a [Wait] block will not end the project.
-
If the students are using a computer, remind them to disconnect the USB cable from Robot Brain before running the project.
-
Since VEXcode V5 has autosave, there is no need to save the project again.
Motivate Discussion - Understanding the Blocks
Q: Viewing the robot's current position at zero degrees, If the robot turned left 90 degrees, then turned right 120 degrees, and finished by turning left 40 degrees, how many degrees would the robot currently be at after it finished turning?
A: The robot will be at 10 degrees. After turning left 90 degrees, the robot turned right 120 degrees. Viewing turning left as moving in a positive direction and turning right as subtracting or moving in a negative direction - similar to an x-y coordinate plane, this now puts the robot at -30 degrees. Since 90-120 = -30. From -30 degrees, the robot turns left 40 degrees. Thus, -30 + 40 = 10. The robot ends at 10 degrees.
Q: Viewing the robot's current position at zero degrees, turning the robot 30 degrees to the right will have the robot finish in the same spot as starting from zero degrees and turning the robot 330 degrees to the left. If the robot turned right 56 degrees and, how many degrees to the left will the robot have to turn to end in the same place assuming it starts from zero degrees?
A: Since turning the robot around fully is 360 degrees, you can add and subtract from 360 degrees to calculate how the robot will need to turn. 360 - 56 = 304. Thus, the robot will have to turn 304 degrees to the left to end in the same place as turning 56 degrees to the right.
Step 6: Complete the Security Camera Challenge!
In the Security Camera Challenge, the robot must start by turning to the right 90 degrees. The robot will then turn to the left 180 degrees then right 180 degrees “scanning” just like a security camera. The robot will then repeat turning 180 degrees to the left and 180 degrees to the right an additional two more times. Thus, the robot will scan 180 degrees three times total.
Before programming the robot, plan out the robot's path and behaviors in your engineering notebook.
After completing the Security Camera Challenge, you will be able to combine forward and backwards movements with additional robot behaviors to complete even more advanced challenges.
Teacher Toolbox - Solutions
Teacher Tips
Validate that the robot successfully completed the challenge by watching the robot's starting position, and count to ensure that the robot has performed the correct actions. The robot should turn right for 90 degrees, then repeat three times: a turn left for 180 degrees and a turn right for 180 degrees.