0% found this document useful (0 votes)
55 views11 pages

Color Follower Sensor

The document provides instructions for creating a line follower program using the EV3 that will follow a line until it detects a specific color and then stop. It includes steps to create a simple line follower, modify the loop exit condition, make a My Block with inputs, and wire the My Block.

Uploaded by

Rasha Al Khatib
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)
55 views11 pages

Color Follower Sensor

The document provides instructions for creating a line follower program using the EV3 that will follow a line until it detects a specific color and then stop. It includes steps to create a simple line follower, modify the loop exit condition, make a My Block with inputs, and wire the My Block.

Uploaded by

Rasha Al Khatib
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/ 11

INTERMEDIATE

PROGRAMMING
LESSON

C OLOR LINE FOLLOWE R M Y B LOC K WIT H INPUT S:


M OVE UNT IL B LAC K
By Sanjay and Arvind Seshan

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 1


Lesson Objectives
1. Learn how to write a line follower that takes multiple inputs
2. Learn how to write a line follower that stops when it sees a another line
3. Practice making useful My Blocks

Prerequisites: My Blocks with Inputs & Outputs, Data Wires

The code uses Blue Comment Blocks. Make sure you are running the most recent
version of the EV3 Software. EV3Lessons has Quick Guides to help you.

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 2


Tips to Succeed
1. You will need to know how to make a Simple Color Line Follower program and
how to make a My Block with inputs
2. Since you will use your EV3 Color Sensor in Color Mode, you will not have to
Calibrate your color sensor for this lesson
3. Check which ports you have your color sensor connected to the EV3 and adjust
the code as needed
4. You may have to adjust the speed or direction to work for your robot. Make
sure that the the color sensor is in front of the wheels in the direction of
travel.
5. Make sure you place the robot on the side of the line that you are following.
The most common mistake is placing the robot on the wrong side of the line to
begin with.

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 3


Color Follower Until Color
Challenge: Create a line follower My Block that stops when it sees black
STEP 1:
• Create a simple line follower
STEP 2:
• Change the loop exit condition to
“until black”
STEP 3:
• A. Make a My Block with 3 inputs:
Power, Color to line follow on, and
Color to stop at
• B. Wire the My Block

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 4


Step 1: Simple Line Follower

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 5


Step 2: Loop Exit Condition

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 6


Step 3A: Create a My Block
A. Highlight all the blocks
then go to My Block A
Builder

B. Add 3 inputs: one for


power and one for color,
and one for degrees

• Refer to the My Blocks B


with Inputs & Outputs
lesson if you need help
setting up the My Block

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 7


Step 3B: Wire the My Block

Color to line follow Color to stop at

Power

C • The color to stop at goes into loop exit condition


• The power input goes into power input on the steering block
• The color input goes into color input for the switch

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 8


Step 3B: The My Block
• Now the My Block appears in the
turquoise tab and the same My Block
can be used again and again with new
inputs (see left)
• The first block solves the challenge
and follows a red line until it sees the
robot sees black
• The second block in this code is to
show that the same block can be used
with different inputs
• If you want to learn smoother line
followers, proceed to the
proportional control lesson in
Advanced.

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 9


Next Steps
• We use a simple line follower in this lesson. You can combine these techniques
with any line follower.
• Learn how to create a proportional line follower for light or a smooth line
follower for color à check out our Advanced: Proportional Line Follower lesson.

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 10


Credits
This tutorial was created by Sanjay Seshan and Arvind Seshan
More lessons are available at www.ev3lessons.com

This work is licensed under a Creative Commons Attribution-


NonCommercial-ShareAlike 4.0 International License.

© 2016 EV3LESSONS.COM, LAST EDIT 7/06/2016 11

You might also like