14. Introduction to MY BLOCKS

You must first complete 13. Proportional Control before viewing this Lesson

Whenever the robot is going to repeat an action inside your program

When code is repeated in a different program

Organize and simplify your code

14.1. When to use My Blocks

14.2. Parametrization of My Blocks

Parametrization, also spelled parameterization is the process of defining or choosing parameters.

Question: Look at the list of three My Blocks below. Which ones do you think are useful for to use?

– Move5CM (Moves the robot five centimeters)
– MoveCM with a centimeter and power input
– MoveCM with centimeter, power, angle, coast/brake, etc. inputs\

Practical example: For this lesson, our goal is to move a desired amount of rotations at a desired power and return the ultrasonic value at the end

Question: What would be the input(s) and output(s) for our My Block?

Answer: The inputs are power and rotations. The Output is distance measured by the ultrasonic sensor.

Step 1: Highlight Blocks

Select the two blocks in the code that you want to turn into a My Block

Step 2: Launch My Block Builder

A: Go to Tools – My Block Builder
B: Pick – My Block Name
C: Add a Description
D: Select an Icon for the whole My Block

Step 3: Add Inputs/Outputs

A. We need to add two inputs and one output so we will click the + button three times
B. Go back to the first parameter
C. Go to Parameter Setup

Step 4: Setup Parameter for Power

A. Pick a Name
B. Select Input
C. Power is a Number
D. Choose a default value
E. Choose button Style

Step 5: Setup Parameter for Rotation

Step 6: Setup Parameter for Ultrasonic

Step 7: Setup Parameter Icons

In this step, we will change the icons for the parameters from “a” to an image of your choice.
Click on a parameter
B. Click on the tab Parameter Icons if not already on this tab, and choose an icon
C. Repeat steps A and B for each parameter
D. Press Finish when you are done.

Step 8: Add Data Wires

Back to: Module 3. Programming