Using VEXcode VR Switch to Transition from Blocks to Text-Based Coding

While beginner programmers are more inclined to use the block-based interface, more advanced students may be interested in coding their robot using a text-based programming language, like Python. Historically this transition from blocks to text-based programming can feel to students like learning an entirely new language, where they cannot apply the logic they had previously learned using blocks.1 VEXcode VR Switch was developed in order to facilitate that transition from block-based to text-based programming. This article will cover how to use VEXcode VR Switch and walk you through a classroom scenario to explain and illustrate those features in context.

Screenshot 2023-08-01 at 1.20.50 PM.png

Using Switch Blocks

Switch incorporates familiar elements of block-based programming and integrates text-boxes where text commands can be typed. This allows the students to slowly transition to text as they learn the commands and syntax that goes along with Python.

Switch provides students a natural bridge from Blocks into text-based coding. As students gain familiarity with the logic and sequencing of commands, they can begin to convert a project one block at a time. 

This allows students to continue working with the logic flow of a block-based program where they can physically see things like the wrapping of a loop around other blocks while also beginning to experiment with text commands themselves. Once the blocks are converted to Switch, students can easily change parameters and begin to understand the syntax of the text command. This section will walk you through a student's use of Switch to explain how you can use these blocks in a VEXcode VR project.

Switch is available with a VEXcode VR Premium license. Learn more about VEXcode VR subscriptions here.

Once you have your license, learn how to access Switch using the information in this article.

Switch in the Classroom

Austin is a student who has been coding with blocks for several years. While some students in the class are still new coders, Austin wants to learn more about Python and how to move into coding the VR robot using text. Ms. Hunter, the Computer Science teacher, noticed that Austin was ready for an additional challenge and introduced Switch to help scaffold Austin's learning and introduce text-based coding. Ms. Hunter demonstrated some of the basics like converting a block and opening the Help to learn more about the Switch Python command for each of the blocks. 

Today Ms. Hunter assigned the Coral Reef Cleanup activity to the class. She uses VEXcode VR for her coding classes because she knows that she can differentiate her instruction and reach students of varying coding levels with the same activities. Switch mode helps to facilitate that differentiation for students like Austin. In the Coral Reef Cleanup activity, the goal is to collect as much trash as possible before the battery runs out on the VR Robot. Understanding the challenge and how to code basic algorithms, Austin creates a VEXcode VR project that uses the Down Eye Sensor to detect the border of the Playground and drive in reverse to avoid harming the coral.


Converting a Single Block to Switch

Convert 1 block

Now that Austin has a project he has tested and verified works, the next step is to convert a block to Switch in order to begin exploring Python. 

Blocks can be converted to Switch by long pressing or right clicking on the block, then selecting the ‘Convert to Switch Block’ option, as shown in the video here.

Austin can now see that the [Drive for] block turned into the drive_for Python command. After converting, Austin runs the project to ensure it still works as intended. After the conversion, Austin wants to learn more about the drive_for command. By opening the Help of the [Drive for] block, Austin can make connections between the parameters from the block to the Python command.

Using the Help to learn more about Switch Python Commands

Open Help

In order to look at the Switch Python Command information in the Help, Austin opens the Help window and selects the [Drive for] block, then scrolls to the bottom as shown in the video here. 

Ms. Hunter checked in and could see that Austin was learning more about the [Drive for] block. She challenged him to apply what was learned from converting a block and typing into a new block. She showed how to drag a Switch block in, and had Austin try to type a turn_for command into the block. Austin open the Help for the block and makes a note about the structure of the command. 

Typing in a Switch Block

Add a block

Knowing the Python command from checking the Help, Austin wants to type directly into a Switch block. Dragging a [Switch Stack] block from the Toolbox, Austin adds it above the [Turn for] block. 

Type in the block

Then Austin uses the cursor to select the Switch block and begin typing the turn_for Python command as shown here. 

After typing in the new command and ensuring the parameters match the original block, the [Turn for] block can be deleted. 

Ms. Hunter comes around to check on Austin’s progress. She sees the Switch project and asks to see it run to ensure the commands are typed correctly. After verifying the project works, she demonstrates another feature - multi-line blocks.

Copy and Paste

The [Switch Stack] block can have multiple lines of code typed within it. Austin copies the turn_for text and pastes it into the block above as shown in the video here.


Austin sees that by hitting ‘enter’ or ‘return’ on the keyboard, additional lines can be added to the block, and continues adding Python commands.

Feeling like a master of Drivetrain commands in Python, Austin prints out a certificate and saves the project for next time.

Converting Stacks to Switch

Later in the school year, Ms. Hunter revisits the Coral Reef Cleanup activity and challenges students to either earn a higher score or use text-based coding. While Austin has been using Drivetrain commands in Switch blocks, this activity is an opportunity to learn more about the equivalent of ‘C’ blocks and Booleans in Python. 

Convert wrapper

Austin long presses or right clicks on the [If then else] block and selects ‘Convert wrapper and contents to Switch Block.’ This converts the loop and the contents of the loop to a single Switch block.

Note the indentation after the conversion is complete. Multiple commands in one Switch block must have the proper indentation to work as intended.

Additional Switch Blocks

While Austin has been exclusively using the [Switch Stack] block, there are additional Switch blocks available. Austin is ready to turn in an improved Coral Reef Cleanup project, but makes a plan with Ms. Hunter to try a new kind of Switch block like those listed below in the next class.

Switch blocks follow the same shape conventions as other blocks. The table here shows the comparison between the block shape, its meaning, and the Switch blocks of the same type.

Block Shape Description Block Examples Switch Examples
Hat blocks Start a stack of blocks and are shaped to attach blocks below them. define print name block Screenshot 2023-07-28 at 17.09.19.png
Stack blocks Perform main commands. They are shaped to attach above or below other stack blocks. drive for stack block Screenshot 2023-07-28 at 17.09.22.png
Boolean blocks Return a condition as either true or false and fits inside any blocks with hexagonal (six-sided) inputs for other blocks. left bumper pressed block Screenshot 2023-07-28 at 17.09.27.png
Reporter blocks Report values in the form of numbers and fits inside any blocks with oval inputs for other blocks. timer in seconds block Screenshot 2023-07-28 at 17.09.30.png
C blocks Loop the block(s) within them or check if a condition is true or false. They are shaped to attach stack blocks above, below, or inside them. forever loop block if then else block Screenshot 2023-07-28 at 17.09.34.png Screenshot 2023-07-28 at 17.09.38.png

Putting It All Together

As Ms. Hunter watched Austin test out typing different Python commands in Switch blocks, she could see how Switch allowed her students to scaffold their own learning. Her students all had different coding experiences before beginning her class, and the challenges within VEXcode VR allow them to code at their own levels. Some students code solely in Blocks, some in Python, and others, like Austin, use Switch to transition into Python coding. Over the next few months, Austin moved to coding exclusively in Python, applying the learning from using Switch to make the transition from blocks to text much easier and smoother. 

VEXcode VR Switch allows teachers, like Ms. Hunter, to be facilitators of learning while students of all different coding levels complete the same challenge. All while the students, like Austin, feel empowered to try new methods of solving coding activities as they transition from blocks to text using VEXcode VR Switch.

1  Weintrop, David, and Uri Wilensky. "How block-based, text-based, and hybrid block/text modalities shape novice programming practices."  International Journal of Child-Computer Interaction 17 (2018): 83-92

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: