0% found this document useful (0 votes)
109 views

Lesson 4 Modes of Loop Block

The document discusses the loop block in EV3 programming. The loop block allows tasks to be repeated by placing blocks inside the loop block. It has different modes that control how it repeats including unlimited, count, logic, and sensor-based modes. The loop block provides a more efficient way to program repetitive tasks compared to using only linear programming.

Uploaded by

Alex Serrano
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views

Lesson 4 Modes of Loop Block

The document discusses the loop block in EV3 programming. The loop block allows tasks to be repeated by placing blocks inside the loop block. It has different modes that control how it repeats including unlimited, count, logic, and sensor-based modes. The loop block provides a more efficient way to program repetitive tasks compared to using only linear programming.

Uploaded by

Alex Serrano
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

THE LOOP BLOCK

Learning Objectives:
At the end of the lesson, the students are expected to:
1. Show understanding of the functions of loop block in the
program;
2. Configure the loop block in the mode selector;
3. Apply different modes of loop block to solve complicated task
The Loop Block
Another important ad powerful block used in EV3 software
is the loop block. This is very effective if you want to
perform a certain task over and over again. Like in the
case of making a square program, using the linear method
takes you eight blocks to accomplish such task. The
process is very tasking and time consuming. With the help
of the loop block you will just use two blocks, one is going
forward and the other one going to the right or left
depending on how you accomplish the task.
The good thing with this block
compared to its predecessor is
that it has nodes. You can easily
resize it by manipulating its nodes
and can make a space for the
incoming blocks. The block
stretches involuntarily to fit new
blocks once the block is removed.
One advantage of the loop in EV3 is you can name
the loop so it is easy for you to terminate it by calling
it in any part of the program.

Once the mode selector is selected, it will prompt


you with the different sensor modes, Motor Rotation,
Energy Meter, Timer, Brick Buttons, Unlimited,
Count, Logic and the time.
The Unlimited Mode
The default mode for a loop is
unlimited, once you drag a
motor block inside the loop
block, the sequence will
repeat forever.
The Loop Count
Selecting the count mode
allows you to specify number
of times you want your robot
to run. In the figure at right,
the robot will move forward
for one rotation and then
brake. This will repeat for 5
times
The Loop logic Mode
Choosing Logic in the mode selector is one of the
most powerful programming techniques. The
block of codes inside the loop will repeat until it
encounters a true or false logic signal through a
data wire. In this structure, if the distance is less
than 50 inches the loop will terminate.
Brick Buttons
The brick button works like a
touch sensor, it has three state;
released (0), pressed (1) and
bumped (2). The only difference is
that the brick has 5 buttons; the
left (1), center (2), right (3), up (4)
and down (5) buttons. You can
actually check two buttons, or
more. The process will repeat
unless Brick buttons are being
pressed.
The Color Sensor
This mode has 3 sub commands, the Color,
Reflected Light Intensity and Ambient Light
Intensity. It accepts 7 colors compared to NXT.
The block inside will repeat unless it sees a color.
Red is enabled in the diagram it has a value of 5. If
the robot detects it then it stops immediately.
The Reflected Light Intensity
A sub command in the color mode, it
determines the dark and the light. The
configuration is similar to the wait for
dark or light. It is used to get the
threshold value inside the close area.
The threshold value depends on the
available light in the room. The
compare type has five comparison
value, these are: equal (0), not equal
(1), greater than (2), greater than or
equal to (3), less than (4) and less than
or equal to (5). Click the threshold value
area then type the right value
The Ambient Light Intensity
Another command in the color
mode, determines the light
intensity outside the room.
The sunlight is the main
source of light in this mode.
Like reflected light, it has also
5 compare type.
The Gyro Sensor
The gyro sensor detects an angle. The program
below will stop if the specified angle is reached.
The Infrared Sensor Mode
The sensor tells the
approximate distance of the
robot to the object using
infrared light. It also
communicates with the
remote infrared beacon. It
measures a distance like an
ultrasonic sensor but it doesn’t
work with the remote.
Proximity Mode
The distance of the sensor from the object is
measured with the proximity mode. The sensor
value ranges from 1% to 100%. Increasing the value
will return 100 as the maximum value.
Motor Rotation
The rotation sensor measures
the rotation of the motor. In
the figure at right, the motor
turns 45 degrees then brakes
until the motor at Port A spins
exactly 90 degrees. In this
case, the motor spins twice
since the motor does not
reach 90 degrees.
Touch Sensor Mode
This mode has three states; released (0), pressed
(1) and bumped (2). In the example, the motor will
run forward at 50rpm unless the touch sensor is
pressed then the robot will stop.
Ultrasonic Sensor Mode
This mode measures the distance of the sensor to
the object. The sensor emits radio frequency then it
bounces back and determines its distance. It has
also 5 compare types, it measures the distance in
centimeters, inches and presence/ listen. In the
example at right the motor moves continuously
until it reaches a distance less than 50 cm then the
robot stops.
NXT Sound Sensor Mode
This sensor supports the NXT
sound sensor and
distinguishes sound in dB and
dBa. You can also use this
sensor if you want your robot
to start and stop moving, once
it senses a sound range.
Messaging
This mode is also useful especially if your robot
wants to perform something once it receives a
message from another EV3 Brick.
Loop Interrupt Block
The EV3 language added the Loop Interrupt block
that could immediately terminate a particular loop.
The block calls for the name of the loop then
terminates it. You can terminate a loop from inside
or to end a loop that’s running in a parallel
sequence.
The loop Robot will terminate once the touch
sensor is pressed.

You might also like