Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
61 views17 pages

EV3 My Blocks for STEM Pros

The document discusses how to create custom blocks called My Blocks in the EV3 programming software. It explains what My Blocks are, when to use them, and provides step-by-step instructions to build a My Block that moves a robot a set number of rotations at a given power and returns the ultrasonic distance. Creating My Blocks can simplify code and make programs more readable.

Uploaded by

promsfriday
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views17 pages

EV3 My Blocks for STEM Pros

The document discusses how to create custom blocks called My Blocks in the EV3 programming software. It explains what My Blocks are, when to use them, and provides step-by-step instructions to build a My Block that moves a robot a set number of rotations at a given power and returns the ultrasonic distance. Creating My Blocks can simplify code and make programs more readable.

Uploaded by

promsfriday
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Intermediate Level

My Block
Intermediate Programming Lessons
STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB
1
Lesson Objectives
Learn how to make custom blocks in the EV3 Software (My
Blocks)
Learn why a My Block is useful
Learn to construct a My Block with Inputs and Outputs
(Parameters)

Note: The new features mentioned in this lesson are


available in V.1.3 of both Home Edition and Education
Edition. Update your software if you are not running this
version.

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


What is a My Block?
• A My Block is a combination CM

of one or more blocks that


you create that can be
grouped into a single block
• My Blocks are basically your The two blocks above are
own custom blocks examples of My Blocks:
• Move_Inches tells the robot
• Once a My Block is created, to move the number of inches
you can use it in multiple we input
programs • Turn_Degrees tells the robot
to turn the amount we input
• Just like any other block in
EV3, My Blocks can have • These My Blocks will be
both inputs and outputs taught in separate lessons.
(parameters) 3

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


When do You Use a My Block?

• 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
4

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Why Should You Bother?
Because of My Blocks, your missions will look like this…

Instead of this….

This makes your code easier to read and easier to modify!!!


5
STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB
What Makes a Useful My Block
Note: Making My Blocks with inputs and outputs can make them far more useful.
However, you need to be careful not to make the My Block too complicated.

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

Answer:
◦ Move5CM may be used often, but you will be forced to make other My Blocks for other
distances. This will not be fixable later.
◦ MoveCM with centimeters and power as inputs is probably the best choice.
◦ MoveCM with centimeters, power, angle, coast/brake, etc. might be most customizable,
but some of the inputs might never be used. 6
STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB
Step 1: Highlight Blocks
• For this lesson, our goal is to
move a desired amount of • Question: What would be the input(s)
rotations at a desired power and output(s) for our My Block?
and return the ultrasonic • Answer: The inputs are power and
value at the end rotations. The Output is distance
measured by the ultrasonic sensor.

• Step 1: Select the two


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

7
STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB
Step 2: Launch My Block Builder
• A: Go to Tools → My A
Block Builder - If you
encounter an error, view
the next slide

• B: Pick a My Block Name

• C. Add a Description

• D. Select an Icon for the


whole My Block B Move Rotations and output
Ultrasonic C

8
STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB
Common Error Messages
ERROR 1:

SOLUTION: You need to highlight the blocks before going into My Block Builder
ERROR 2:

SOLUTION: Un-highlight the start block before going into My Block Builder
If you continue to have trouble at this step, just select a single block in your
program and create a My Block from it. You can edit and add more blocks to a
My Block at any time. You can even change the inputs and outputs* of a My Block
after creation.
9

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Step 3: Add Inputs/Outputs
A
A. We need to add two
inputs and one output so Move Rotations and output

we will click the + button


Ultrasonic

three times

B
B. Go back to the first
parameter C Move Rotations and
output Ultrasonic

C. Go to Parameter Setup
10

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Step 4: Setup Parameter for Power

Move Rotations and output


Ultrasonic

A. Pick a Name A E

B. Select Input B
C. Power is a Number C
D
D. Choose a default value
E. Choose button Style
Set min & max values (only available with slider) 11

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Step 5: Setup Parameter for Rotation

Now click on the


second parameter

Move Rotations and output


Ultrasonic

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

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Step 6: Setup Parameter for Ultrasonic

Now click on the


third parameter

Move Rotations and output


Ultrasonic

A
A. Pick a Name
B
B. Select Output C
C. Ultrasonic output is a
Number

13

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Step 7: Setup Parameter Icons
In this step, we will
change the icons for the
parameters from “a” to
an image of your choice.

A. Click on a parameter
A
B. Click on the tab
Parameter Icons if not
already on this tab, and
choose an icon B

C. Repeat steps A and B


for each parameter

D. Press Finish when you


are done.
C 14

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Step 8: Add Data Wires
A. When you click Finish (on These grey blocks are our inputs/outputs
previous slide) you will see (parameters) that were set up automatically by
this. the My Block Builder

B. Wire up the My Block by


dragging a data wire from
each parameter to its
corresponding slot on the
move steering block and
sensor block.

15

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Where is the My Block?
A. Your My Block will appear in the
turquoise tab. You can now use
this block in any program.

B. Below, the same My Block is used


twice. Once to move forward 2 Note: The same My Block can
rotations and then backwards 5 be used with different input
rotations. values.

16

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB


Editing Your Newly Created My Block

If you want to change anything in


the My Block you just created,
simply press on the “Edit” button
on the top Left corner of the My
Block*

You can change the name, add or


delete parameters, etc.

17

STEM PROFESSIONALS CLUB....AFRICA’S #1 STEM LEARNING CLUB

You might also like