Using My Blocks in VEXcode V5

My Blocks is one of the block categories within VEXcode V5. Some other categories include Looks, Sound, Sensing, and Variables. My Blocks are used to create a sequence of blocks that can be used multiple times throughout a project.


How to Make a Block

VEXcode V5 blocks Toolbox with the My Blocks category shown and the Make a Block button highlighted.

Select ‘Make a Block’ from the My Blocks category.

VEXcode V5 Make a Block menu has been opened. The name of the block has been changed to Drive in and it is highlighted. The OK button below is also highlighted.

Rename the block by entering in the ‘Block Name’ field, then select ‘OK.’


How to Customize a Block

Add an input (number)

VEXcode V5 Make a Block menu is open and the name of the block is set to Drive in. A number input field has been added to the block and is now highlighted.

Select the, ‘Add an input (number)’ option from the ‘Make a Block’ screen. Rename the input by entering in the ‘number’ field, then select ‘OK.’

Add an input (Boolean)

VEXcode V5 Make a Block menu is open and the name of the block is set to Drive in. A boolean input field has been added to the block and is now highlighted.

Select the, ‘boolean’ option from the ‘Make a Block’ screen. Rename the input by entering in the ‘boolean’ field, then select ‘OK.’

Add a label

VEXcode V5 Make a Block menu is open and the name of the block is set to Drive in which is followed by a number input. A label field has been added to the end of the block and is now highlighted.

Select the, ‘Add a label’ option from the ‘Make a Block’ screen. Rename the label by entering in the ‘Label Text’ field, then select ‘OK.’

Combine inputs and labels

VEXcode V5 Make a Block menu is open and a custom block has been created. The block first reads Drive in, then there is a number input field, and then ends with a label reading mm Square. All together the custom block reads Drive in X mm Square. The OK button is highlighted below.

Combine inputs and labels together in order to create a sequence of blocks, then select ‘OK.’


How to Delete Inputs / Labels

VEXcode V5 Make a Block menu is open and the name of the block is set to Drive in. A number input field has been added to the block, and the Clear icon above the new input field is highlighted.

To delete an input or label, select the ‘Clear’ icon on top of the input or label that you wish to remove.


How to Use the Define Block

VEXcode V5 My Blocks Definition block is highlighted in the Workspace. The defined block reads 'Drive in number mm square', and the word number is a number parameter that can be used in the block definition.

A parameter can now be used from the {Define} block once it is created.

The VEXcode V5 My Blocks Definition block with a code definition now added to it. The stack has a Repeat block set to 4, and a Drive for 200 mm block with a Turn for 90 degrees block both inside the Repeat block.

Attach additional blocks to the {Define} block.

The VEXcode V5 My Blocks Definition block with the number parameter now used in the definition. The stack has a Repeat block set to 4, and a Drive for block above a Turn for 90 degrees block inside the repeat block. The number parameter has been placed into the Drive for block, so the block now reads Drive forward for number mm.

Use parameters from the {Define} block.

VEXcode V5 My Blocks command block added below a When Started block to run the new block. This command block will call the Drive in number mm square command. The number parameter is set to 300.

Use the [My Block] attached to the {When Started} block.


How to Use My Blocks

Driving in Squares Example

In this example, the robot will use My Blocks to:

  • Drive forward in a 200 mm square.
  • Turn right 45 degrees.
  • Drive forward in a 300 mm square.

The {Define} hat block breaks down a procedure. In this example video, this {Define} hat block breaks down the blocks used to drive in a square a certain number of times. Drag arguments from the {Define} block to be used within the blocks.

Once the {Define} block is set, the newly created block can now be dragged and added to the {When Started} block to set parameters. This process is shown in this video.

VEXcode V5 blocks project that uses a When started block to run the custom Drive in number mm square block twice. The When started stack reads When started, Drive in 200 mm square, turn right for 45 degrees, and then Drive in 300 mm square.

Once the parameters are changed, the project is ready to be Download and Run.

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

Last Updated: