My Blocks - Tutorials - VEXcode IQ Blocks

 My Blocks is one of the block categories within VEXcode IQ Blocks. 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

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

Make_a_Block.png


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

Rename_a_block.png 


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

Input_a_number.png

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

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

Add_a_label.png 

Combine inputs and labels

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

Combine_inputs_and_labels.png


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.

Delete_label___input.png


How to Use the Define Block

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

Define_block.png 

Attach additional blocks to the “define” block.

 Add_blocks_to_define.png

Use parameters from the “define” block.

 Use_paramaters_in_define_block.png

Use the “My Block” attached to the “When Started” block.

Attach_to_When_Started.png 


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.

 Play_siren_example.png

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.

unnamed.png