The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by eng.hd10, 2019-03-23 16:46:22

Ev3 Programming2

Ev3 Programming2

1. If we are on black, keep going 101
straight

2. If we are on white, turn left to get
back to the line

OH NO… my robot is running
away….

When the robot leaves the left
side of the line, the program no
longer works!

© 2015 EV3Lessons.com (Last edit: 2/28/2015)

LINE FOLLOWING: ROBOT 102
STYLE

Why could the Human follow the middle?:
• They can see ahead.
• They can see the whole line and its surroundings
• They see both sides and which side they left

Why can’t the Robot do the same thing?:
• Can’t tell right or left side of the line
• How do we make sure the robot always veers off on the
SAME SIDE of the line?

• Instead of the middle, could the robot follow the “edge”?

• So now the robot will fall off only the same side.
• We will now show you how this works!

© 2015 EV3Lessons.com (Last edit: 2/28/2015)

ROBOT LINE FOLLOWING

HAPPENS ON THE EDGES
Left side line following Right side line following

If on The robot has to If on
black, choose which black,
turn left. turn
If on way to turn when right.
white the color sensor If on
turn sees a different white
right. turn left.
color.

The answer 103
depends on what

side of the line
you are following!

© 2015 EV3Lessons.com (Last edit: 2/28/2015)

STARTING THE ROBOT ON THE
CORRECT SIDE

✔ ✔✗

© 2015 EV3Lessons.com (Last edit: 2/28/2015) 104

LINE FOLLOWER CHALLENGE 1

Step 1: Write a program that follows the RIGHT edge
of a line.

Hints: If your sensor sees black, turn right. If your
sensor sees white, turn left. Use loops and switches!

Step 2: Try it out on different lines.

Did your line follower work the same on
straight and curved lines?

Step 3: If not, instead of turn Steering = 50, try
smaller values.

Is it better on the curved lines now?

B
C
B
C

© 2015 EV3Lessons.com (Last edit: 2/28/2015) 105

LINE FOLLOWING CHALLENGE
SOLUTION

Q. Does this program follow the Right or Left side of a line? 106
A. The robot is following the Right Side of the line.

© 2015 EV3Lessons.com (Last edit: 2/28/2015)

CHALLENGE 1 SOLUTION

Q. This line follower goes forever. How do we make this stop? 107
A. Change the end condition on the loop.

© 2015 EV3Lessons.com (Last edit: 2/28/2015)

LINE FOLLOWER CHALLENGE 2

Part 1: Make a line follower that stops when you
press the touch sensor

Part 2: Make a line follower that stops after it
travels a particular distance

© 2015 EV3Lessons.com (Last edit: 2/28/2015) 108

CHALLENGE 2 SOLUTION:
SENSOR

© 2015 EV3Lessons.com (Last edit: 2/28/2015) 109

CHALLENGE 2 SOLUTION:
PARTICULAR DISTANCE

© 2015 EV3Lessons.com (Last edit: 2/28/2015) 110

DISCUSSION GUIDE

Why is it important for the robot to follow the same side of the
line?

The robot only knows to check if it is on or off the line.

This is a basic line follower. What are some things that were not
good about this line follower? Do you think the line follower can
be improved?

It wiggles a lot. Smoother line followers are described in the
Advanced lessons

What sensor measures how far you have travelled?

The rotation sensor used in Challenge 2 solution measures
how much the wheels have turned

How would you write a line follower that will stop when it sees a
line? Or another color?

Change the loop exit condition to use the color sensor.

© 2015 EV3Lessons.com (Last edit: 2/28/2015) 111

BEGINNER EV3
PROGRAMMING

LESSON

Topics Covered:
Basic Sequencer

LESSON OBJECTIVES

1. Learn how to use the Wait for Button Press Block
2. Learn what a Sequencer is and why it is useful
3. Learn how to make a Sequencer

Copyright EV3Lessons.com © 2015 Last edit 2/28/2015 113

USING EV3 BRICK BUTTONS AS
A SENSOR

All the EV3 brick buttons (except the OFF button) are like the
touch sensor
You can use the buttons to make a game, run different
actions based on each button, or make a sequencer (explained
on slide 4).
You do not need to waste a sensor port on a touch sensor if
you plan to use the touch sensor like a button.
The first step to making a Basic Sequencer is to learn how to
use the “Wait for Button Press” feature. See next slide (slide 3)

Copyright EV3Lessons.com © 2015 Last edit 2/28/2015

114

HOW TO USE A “WAIT FOR
BUTTON PRESS” BLOCK

Wait Block – Click on the bottom left corner
and select Brick Buttons – Compare – Brick
Buttons
This slide is animated.

Droids
recommend
#2
(bumped) –
most
reliable
You can choose
any button
except the off
button

Copyright EV3Lessons.com © 2015 Last edit 2/28/2015 115

WHAT IS A SEQUENCER AND
WHY USE ONE?

A sequencer is a program that puts your missions in the order you
choose. It is sometimes called a Master Program or a Menu System.
Advantages: You will not need to search for the program in a jumble of
programs on the brick. This will save you time on your runs.
Disadvantages: You will not be able to re-run each program easily with a
basic sequencer (check our more advanced Menu System lesson)

Programs on brick Sequencer

Copyright EV3Lessons.com © 2015 Last edit 2/28/2015

116

STEP 1: CREATE A “DUMMY”
SEQUENCER

Create a Sequencer that waits until you
press the button to play the (next) actions.
This will also display which mission will be
played next. “Dummy” just means that
you don’t have your actions yet.

Copyright EV3Lessons.com © 2015 Last edit 2/28/2015

117

STEP 2: ADD ACTIONS

Copy and paste each of your actions after each button
press. Note: these missions just move and turn (don’t
really do much!). Replace with your own code.

This sequencer code is set up for 3 actions (add/remove as needed) 118

Copyright EV3Lessons.com © 2015 Last edit 2/28/2015

DISCUSSION GUIDE

What did this sequencer allow you to do? Why is this useful?
• It let you run one action on your robot after another. On the EV3
Brick, it can be hard to locate your programs. This ensures that
multiple programs you have written will be in a sequence.

Copyright EV3Lessons.com © 2015 Last edit 2/28/2015 119


Click to View FlipBook Version