Programming 201:�Using Force and Distance Sensors
LEGO® Education SPIKETM Prime Word 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.
1
Robot Design: Programming 201 Sensors – Coach Series
Learning Objectives
Recommended Prerequisites:
Programming 101 – Introduction and Common Practices
Programming 101 – Basic Movement
Programming 201 – Line following, Variables and My Blocks
2
Robot Design: Programming 201 Sensors – Coach Series
SPIKE™ Sensor Overview
MEDIUM MOTOR
COLOR SENSOR
LARGE MOTOR
DISTANCE SENSOR
FORCE SENSOR
SPIKE™ HUB
GYRO SENSOR
3
Robot Design: Programming 201 Sensors – Coach Series
Sensors included in the core and expansion sets
Sensor | Core Set (45678) | Expansion Set (45680) |
Force sensor (force, touch) | 1 | 0 |
Color sensor (color, light) | 1 | 1 |
Distance sensor | 1 | 0 |
Medium motor (rotation) | 2 | 0 |
Large Motor (rotation) | 1 | 1 |
SPIKE Prime Hub (gyro, accelerometer) | 1 | 0 |
https://education.lego.com/en-us/product-resources/spike-prime/downloads/technical-specifications/
4
Robot Design: Programming 201 Sensors – Coach Series
Force Sensor – Modes and Specifications
The three Force sensor modes are:
5
Robot Design: Programming 201 Sensors – Coach Series
Force Sensor – Modes and Specifications
6
Robot Design: Programming 201 Sensors – Coach Series
Force Sensor – Pseudocode
7
Robot Design: Programming 201 Sensors – Coach Series
Force Sensor – Basics
8
Robot Design: Programming 201 Sensors – Coach Series
Force Sensor – Basics
9
Robot Design: Programming 201 Sensors – Coach Series
Force Sensor – Basics
Download and test your code.
10
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Force and Gyro Sensors
Using the Gyro sensor to move straight to the target and the Force sensor to stop at the target
Create a My Block named “ForceSensor” with three inputs and labels:
1
3
2
11
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Force and Gyro Sensors
12
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Force and Gyro Sensors
13
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Force and Gyro Sensors
14
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Force and Gyro Sensors
15
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Force and Gyro Sensors
16
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Force and Gyro Sensors
Write a program to test your code.
17
Robot Design: Programming 201 Sensors – Coach Series
Distance Sensor - Basics
Download and test your code.
18
Robot Design: Programming 201 Sensors – Coach Series
Distance Sensor - Description
19
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Distance and Gyro Sensors
Create a My Block named “ForceSensor” with four inputs and labels:
1
3
2
4
20
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Distance and Gyro Sensors
21
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Distance and Gyro Sensors
22
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Distance and Gyro Sensors
23
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Distance and Gyro Sensors
24
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Distance and Gyro Sensors
25
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Distance and Gyro Sensors
26
Robot Design: Programming 201 Sensors – Coach Series
Control Movement with Distance and Gyro Sensors
Write a program to test your code.
0
20
.4
5
.4 x (0 – 0) = 0
Current yaw reading is 0
20
20
.4
0
5
0
0
20 + 0 = 20
20 - 0 = 20
Both motors at same speed = robot move straight
27
Robot Design: Programming 201 Sensors – Coach Series
Everything is awesome!
-Emmet Joseph Brickowski
28
Robot Design: Programming 201 Sensors – Coach Series