You are on page 1of 33

ROBOTICS

(FLOW CONTROL
BLOCKS)`
LEGO MINDSTORMS
Education EV3
FLOWCONTROL
BLOCKS
• Flow Control blocks are the blocks that is being use to manage
the flow of the program that you build.
• This block is best applicable when you want to manipulate a
sequence of a program that will be running.
• There are Five blocks inside the tab of the Flow Control
Blocks and these are the ff:

-Start -Switch
-Wait -Loop Interupt
-Loop
FLOW CONTROL BLOCKS

1. START 3. LOOP 5. LOOP INTERRUPT

2. WAIT 4. SWITCH
START

• The Start block marks the beginning of a programming block


sequence in your program. Your program can have more than
one sequence. All sequences with a Start block will start
automatically when a program is run, and the sequences will
run at the same time.
WAIT

• This block makes your program wait for something before


continuing to the next block in the sequence. The block may
wait on time, sensor values, or a pressed brick button.
WAIT

INPUTS
Seconds: Positive Number
Compare Type: Equal(0), Not Equal(1), Greater Than (2), Greater
Than or Equal To (3), Less Than(4), Less Than or Equal To (5)
Threshold Value: Number
Direction: Number
Amount: Number
WAIT

Mode Selector

3. The 13
different modes
LOOP

• This block works as a repeat. The code inside the loop will
repeat until a certain condition is met. Conditions Include:
Unlimited Once the condition is met, the robot may exit the
loop.
LOOP

INPUTS
Count: Number
Seconds: Number
Until: Boolean
Compare Type: Equal (0), Not Equal (1), Greater Than (2), Greater
Than or Equal To (3), Less Than (4), Less Than or Equal To (5)
Threshold Value: Number
LOOP

Mode Selector

3. The 16
different modes
3 Different Mode of Loop
Block
• Unlimited Mode
• Loop Count
• Loop Logic Mode
SWITCH
• The Switch block is a container
that can contain two or more
sequences of programming
blocks. Each sequence is called a
Case. A test at the beginning of
the Switch determines which
Case will run. Only one Case will
run each time the Switch is
executed.
SWITCH
INPUTS

Logic: Boolean
Number: Number
Text: Text
Compare Type: Equal (0), Not Equal
(1), Greater Than (2), Greater Than or
Equal To (3), Less Than (4), Less
Than or Equal To (5)
Threshold Value: Number 
SWITCH
Mode Selector

3. The 15
different modes
SWITCH VIEW
• Flat View
• Tabbed View
LOOP INTERRUPT

• The Loop Interrupt block makes a Loop block end. No more


blocks in the loop sequence will execute, and the program will
continue with any blocks that are after the loop. You can specify
which Loop block to interrupt by using its Loop Name.
WRITTEN
TEST I
1.This block marks the beginning of a
programming block sequence in your program?
2. What blocks that is being use to manage the
flow of the program that you build?
3. This block works as a repeat?
4. What block makes a Loop block end?
5. What block is a container that can contain two
or more sequences of programming blocks?
Enumeration
6-8. What are the 3 Major Mode of
Loop Block?
9-10. What is the difference
between Action block and Flow
control?
Identify the following block in
Flow Control.
13. 15.
11.

12.
14.
LIGHT/COLOR SENSOR
Anatomy of EV3
Sensors a.k.a. “Eyes”

Color Sensor
• Detects Colors
• Measures Light Intensity
EV3’s Sensor Blocks
The Colour Sensor block gets data from the Colour Sensor. You can
measure the colour or intensity of light and get a Numeric output.
You can also compare sensor data to an input value and get a Logic
(True or False) output.

Port Selector

Mode Selector

Input

Outputs
Line Followers:
Basic to
Proportional
Which Program Works
Best for Which Situation?
Simple Line Follower Smooth Line Follower
• Most basic line follower • Almost the same as simple
• Wiggles a lot due to sharp • Turns are less sharp
turns • Has trouble on sharp curves
• Good for rookie teams  need • Good for rookie teams  need to
to know loops and switches know loops and switches

3-Stage Follower Proportional Follower


• Best for straight lines • Uses the “P” in PID
• Droids do not recommend this. • Makes proportional turns
Just learn the proportional line • Works well on both straight and
follower. curved lines
• Need to know nested switches • Good for intermediate to advanced
teams  need to know math blocks
and data wires
Watch the videos on the next 2 slides to see all four.
© 2015 EV3Lessons.com, Last edit
26
4/5/2015
Curved Line: Watch
Videos
Simple Line Follower Smooth Line Follower

3-Stage Follower Proportional Follower

© 2015 EV3Lessons.com, Last edit


27
4/5/2015
Straight Line: Watch
Videos
Simple Line Follower Smooth Line Follower

3-Stage Follower Proportional Follower

© 2015 EV3Lessons.com, Last edit


28
4/5/2015
3 Line Follower
Challenges
• Challenge 1: Can you write a simple line follower? Hint: Review
Beginner: Basic Line Follower lesson
• Challenge 2: Can you write a smoother line follower? Hint:
Change how sharp the turns are in a simple line follower.
• Challenge 3: Can you write a three-stage line follower where the
robot moves different 3 different ways (left, right or straight)
based on the reading from the color sensor?

© 2015 EV3Lessons.com, Last edit


29
4/5/2015
Solution 1: Simple Line
Follower

© 2015 EV3Lessons.com, Last edit


30
4/5/2015
Solution 2: Smooth Line
Follower

© 2015 EV3Lessons.com, Last edit


31
4/5/2015
Solution 3: Three-Stage
Line Follower

© 2015 EV3Lessons.com, Last edit


32
4/5/2015
Challenge 4: Proportional
Line Follower
Challenge 4: Can you write a proportional line follower that changes the
angle of the turn depending on how far away from the line the robot is?
Pseudocode:
1. Reset the Rotation sensor (Only required for line following for a
total distance)
2. Compute the error = Distance from line = (Light sensor reading –
Target Reading)
3. Scale the error to determine a correction amount. Adjust your
scaling factor to make you robot follow the line more smoothly.
4. Use the Correction value (computer in Step 3) to adjust the robot’s
turn towards the line.
© 2015 EV3Lessons.com, Last edit
33
4/5/2015

You might also like