My Blocks is one of the block categories within VEXcode IQ. 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
Select “Make a Block” from the My Blocks category.
Rename the block by entering in the “block name” field, then select “OK.”
How to Customize a Block
Add an input (number)
Select the, “Add an Input (number)” option from the “Make a Block (Preview)” screen. Rename the input by entering in the “number” field, then select “OK.”
Add an input (boolean)
Select the, “Add an Input (Boolean)” option from the “Make a Block (Preview)” screen. Rename the input by entering in the “Boolean” field, then select “OK.”
Add a label
Select the, “Add a label” option from the “Make a Block (Preview)” screen. Rename the label by entering in the “label text” field, then select “OK.”
Combine inputs and labels
Combine inputs and labels together in order to create a sequence of blocks.
How to Delete Inputs / Labels
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
A parameter can now be used from the “define” block once it is created.
Attach additional blocks to the “define” block.
Use parameters from the “define” block.
Use the “My Block” attached to the “When Started” block.
How to Use My Blocks
Play Siren Example
In this example, the robot will use My Blocks to:
- Play the siren sound 3 times
- Drive forward for 12 inches
- Play the siren sound 6 times
The “define” hat block breaks down a procedure. In the following example, this “define” hat block breaks down the blocks used to play a siren sound 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.
Once the parameters are changed, the project is ready to be downloaded and run.
Print with New Line Example
In this example, the robot will use My Blocks to:
- Drive forward for 15 inches
- Print the battery capacity and also move the cursor to a new line on the Brain’s screen
- Turn the robot 180 degrees to the right
- Print the battery capacity and also move the cursor to a new line on the Brain’s screen
The “define” hat block breaks down the blocks used to print sensor reporter values and then move to a new line. 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.
Once the parameters are changed, the project is ready to be downloaded and run.