Using My Blocks in VEXcode IQ

 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. 

The following article will cover:

  • How to Make a Block
  • How to Customize a Block
    • Add an input (number)
    • Add an input (Boolean)
    • Add a label
    • Combine inputs and labels
  • How to Delete Inputs / Labels
  • How to Use the Define Block
  • How to Use My Blocks
    • Play Siren Example
    • Print with New Line Example

 How to Make a Block

Make_a_Block.png

Select “Make a Block” from the My Blocks category.

Rename_a_block.png

Rename the block by entering in the “block name” field, then select “OK.”


How to Customize a Block

Add an input (number)

Input_a_number.png

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)

Add_a_boolean.png

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

Add_a_label.png

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.png

Combine inputs and labels together in order to create a sequence of blocks.


How to Delete Inputs / Labels

Delete_label___input.png

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

Define_block.png

A parameter can now be used from the “define” block once it is created.

Add_blocks_to_define.png

Attach additional blocks to the “define” block.

Use_paramaters_in_define_block.png

Use parameters from the “define” block.

Attach_to_When_Started.png

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.

Play_siren_example.png

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.

unnamed.png

Once the parameters are changed, the project is ready to be downloaded and run.