SPIKE™ Prime with Python

Safe Delivery

Students will explore how motors and sensors can work together safely.

45 minutos
Intermedio
6.º de primaria a 2.º de secundaria

Questions to investigate

• How can sensors be used to provide safety?

Prepare

• Ensure SPIKE Prime hubs are charged, especially if connecting through Bluetooth.

Engage

(Group Discussion, 5 minutes)

Kate and Kyle are working on adding a new treehouse to the playground. The delivery cart is coming with the needed materials, but Kyle is concerned the cart might damage the other items on the playground.

Ignite a discussion about how to help ensure the cart does not bump into any other materials on the playground. Consider showing an image of a playground as an example to support the discussion and later planning.

Explore

(Small Groups, 20 minutes)

Challenge students to investigate how the Cart can move more safely.

Discuss with students how the cart can move more safely through the playground. Ask students to create a small obstacle course with 2 or 3 items to mimic the playground using objects that are positioned high enough for the distance sensor to “see” them.
Ask students to write a program to allow the Cart to drive forward and stop before hitting an object, thus allowing the cart to move safely through the playground and stop in front of an object. Students should create the program to allow the cart to turn the motor on, until the distance sensor is closer than 20 cm to an object and then stop the motor.

Sample Code:

from spike import DistanceSensor, MotorPair, Motor
from spike.control import wait_for_seconds

\# Initialize the Distance Sensor and motor
distance_sensor = DistanceSensor('B')
motor_pair = MotorPair('E', 'A')
motor_back = Motor('C')

\# Move your hand slowly toward and away from the Distance Sensor
motor_back.run_to_position(0, 'shortest path', 75)
motor_pair.start(0, -50)
distance_sensor.wait_for_distance_closer_than(20, 'cm')
motor_pair.stop()

Have students create a chart to document each run like the one below.

00

Students should run the program 5 times changing the speed for the motor each time. Students should run the program, then read the distance shown on the SPIKE App under the Distance Sensor. Allow students time to complete each trial and fill in the chart.

Explain

(Whole Group, 5 minutes)

Discuss with students what they found when running the program at different power levels.

Discuss the difference between speed and power with students. Explain that when students are setting the speed in the program what they are actually setting is the amount of power the motor will use. This then determines how fast or at what speed the robot is able to travel.

Ask students questions like:
• How did the speed of the cart change when the power was increased?
• How did increasing the speed affect the way the cart is able to stop?
• Which power level or speed allows the cart to stop with the most accuracy?
• How should we consider power level or speed in creating the cart to move more safely?

Elaborate

(Small Groups, 10 minutes)

Challenge students to move through the playground without hitting objects no matter where the cart enters.

Discuss with students how the cart needs to move through the playground to deliver the materials. The cart might enter from different spots. Students should try to run their program from different angles to make sure it can safely to move through the playground without hitting an object by using the distance sensor.

Note: The delivery cart cannot make sharp turns (like a 90-degree turn) but rather makes arc turns.

Students should consider the angles the cart might need to move and change the position of the rear wheels as needed (i.e. not set to the 0 degrees position).

Allow students time to explore how to move safely through the playground.

Discuss how the students were able to use the cart in the playground area.

Asking students questions like:
• How were you able to use the sensor to avoid hitting objects?
• How can sensors be used to add safety to moving objects?
• How did you use the additional motor in the back to help move the cart?
• What was difficult about this challenge?

Discuss different programs with students to prompt them to think about where they are relying on programming the motors to move and where they are using the sensors to decide.

Evaluate

(Group Exercise, 5 minutes)

Teacher Observation
Discuss the program with students. Ask students questions like:
• How did you program the sensor to allow the cart to move more safely?
• Why does the power of the motor or speed affect the way the model reacts when stopping with the distance sensor?

Self-Assessment
Have students answer the following in their journals:
• What did you learn today about setting the power level or speed of the motor when using the sensor to ensure safety and accuracy?
• What characteristics of a good teammate did I display today?
• Ask students to rate themselves on a scale of 1-3, on their time management today.
• Ask student to rate themselves on a scale of 1-3, on their materials (parts) management today.

Soporte para el profesor

Students will:
• Program model to move safely using sensors.
• Investigate effects of motor power when using sensors.

• SPIKE Prime sets ready for student use
• Devices with the SPIKE App installed
• Delivery Cart model, which was used in the Cart Control lesson
• Student journals
• Ruler

CSTA
2-CS-02 Design projects that combine hardware and software components to collect and exchange data.
2-AP-10 Use flowcharts and/or pseudocode to address complex problems as algorithms
2-AP-13 Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
2-AP-16 Incorporate existing code, media, and libraries into original programs, and give attribution.
2-AP-17 Systematically test and refine programs using a range of test cases.
2-AP-19 Document programs in order to make them easier to follow, test, and debug.

Legal NoticePrivacy PolicyCookies

LEGO, the LEGO logo, the Minifigure, DUPLO, the SPIKE logo, MINDSTORMS and the MINDSTORMS logo are trademarks and/or copyrights of the LEGO Group. ©2022 The LEGO Group. All rights reserved. Use of this site signifies your agreement to the terms of use.