Programming 201:�Line following, Variables and My Blocks�
Coach Series
Disclaimer: This private training is provided by the North Texas Region and is not affiliated or operated by the LEGO® Group or by FIRST ®. The LEGO Group® and FIRST® are not responsible for any of its activities.
LEGO® Education SPIKETM Prime Word Blocks
1
Robot Design: Programming 201 – Coach Serries
Learning Objectives
Recommended Prerequisites:
Programming 101 – Introduction and Common Practices
Programming 101 – Basic Movement
2
Robot Design: Programming 201 – Coach Serries
Line Following Basics
Line following is really following the edge of a line and not the line itself. The robot must continually turn towards the edge of the line to stay on course.
Basic concept:
FOLLOW THE LEFT EDGE OF LINE
3
Robot Design: Programming 201 – Coach Serries
Proportional Line Following
Proportion line following has four steps:
4
Robot Design: Programming 201 – Coach Serries
Proportional Line Following
0 reading
50 reading
25 reading
75 reading
100 reading
Light sensor should be mounted 16 mm above the surface it is scanning
Black line with white borders (Typical FLL-C®)
5
Robot Design: Programming 201 – Coach Serries
Proportional Line Following
6
Robot Design: Programming 201 – Coach Serries
Creating Variables
7
Robot Design: Programming 201 – Coach Serries
Creating Variables
NEW VARIABLE DIALOG
8
Robot Design: Programming 201 – Coach Serries
Creating Variables
9
Robot Design: Programming 201 – Coach Serries
Variable Tab
Variables tab displays the current variable value
10
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
11
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
12
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
13
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
14
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
15
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
16
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
17
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
18
Robot Design: Programming 201 – Coach Serries
Proportional Line Following Code
19
Robot Design: Programming 201 – Coach Serries
My Block Overview
20
Robot Design: Programming 201 – Coach Serries
Creating a My Block – Line Follower
From the My Blocks group, select the “Make a Block” button. The Make a Block window displays.
21
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
1. Enter a “block name”
Suggestion: LineFollow
22
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
2. Select “Add an input”
Adds: Input
3. Select “Add a label”
Adds: Label
23
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
4. Select the input area and enter “Value”
5. Select the label area and enter “Target”
24
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
7. Select “Add a label”
6. Select “Add an input”
25
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
8. Select the input area and enter “Factor”
9. Select the label area and enter “Correction”
26
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
11. Select “Add a label”
10. Select “Add an input”
27
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
12. Select the input area and enter “%”
13. Select the label area and enter “Speed”
28
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
15. Select “Add a label”
14. Select “Add an input”
29
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
16. Select the input area and enter “CM”
17. Select the label area and enter “Distance”
18. Select “SAVE”
30
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
1. LineFollow My Block is inserted in the Word Block list and on the Programming Canvas.
31
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
3. Select the “[motor▼] set relative position to [0]” and drag to the LineFollow My Block and connect.
2. Select and drag the GyroTurn My Block to an open position on the Programming Canvas.
32
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
33
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
34
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
35
Robot Design: Programming 201 – Coach Serries
Creating a My Block - Line Follower
36
Robot Design: Programming 201 – Coach Serries
How the My Block Works
A LineFollow My Block insert into the code pass the Target, Correction, Speed, and Distance values to the code.
37
Robot Design: Programming 201 – Coach Serries
Switching side of the line to follow
Create two My Blocks, one to follow the left side and the other to follow the right side.
38
Robot Design: Programming 201 – Coach Serries
Everything is awesome!
-Emmet Joseph Brickowski
39
Robot Design: Programming 201 – Coach Serries