SPIKE™ Prime with Python

Race Day

Students program their model to move through a course considering the best use of motor controls.

45 min
Beginner
Years 7-9 OR Key Stage 3

Questions to investigate

How does the task to complete determine the way a robot needs to move? Why is documenting moves important?

Prepare

  • Ensure SPIKE Prime hubs are charged, especially if connecting through Bluetooth.
  • Ensure students have built the Hopper model, which was used in the Hopper Run lesson.

1. Engage

Ignite a discuss with students about different types of racetracks – tracks for cars, tracks for people, tracks for bicycles, etc. There are many different types of tracks that you can race across. Consider showing videos or images of different types of racetracks.

Challenge students to create a track for the race that includes straight areas and turns.

Each group should design a basic racecourse for Hopper to move through. The course should have at least 5 steps including straight moves and turns.

2. Explore

Students will program their Hopper to run the course.

Discuss with students how Hopper can be programmed to move in the needed ways to run along the trail. Identify different ways that they could get the motors to move without changing the design of the model.

Prompt students to think of different ways that each motor can move to make the model go straight or turn.

  • For example, motor E might move quickly while motor F moves slowly using a Motor Pair tank move.
  • For example, one motor could move using degrees while the other is stopped.

Ask students to write a pseudocode program to explain the needed steps and programming elements to complete the race.

Open a new project in the Python programming canvas.

  • Ask students to erase any code that is already in the programming area.

For this challenge, tell students to include a code comment using the # in their code for each step of the track moves to explain the movement of the model (i.e. moving straight, way it turns, moving backwards).

Encourage students to complete one step of the race at a time. Testing and iterating on the program will be important during this challenge. Remind students to watch their console for error messages and to reference the Knowledge Base as needed for help.

3. Explain

Allow students to share their final programs and how they programmed Hopper.
Ask students

  • How did you program your Hopper to move through the different parts of the race?
  • What debugging issues did you have? Did you have any error messages during programming?
  • What was difficult about this challenge?

Ask students to review the code comments used in their program to determine if the code was documented well and is easy to follow. Discuss several examples as a class to think about best practices in documenting.

4. Elaborate

Allow students to try racing on other courses developed by other groups. Students will need to create a new program in order to complete the new course. Remind students to test their program several times in order to ensure it moves as expected from the pseudocode. Ask students to add code comments using # to explain the steps of the program.

5. Evaluate

Teacher Observation:
Discuss the program with students.

Ask students questions like:

  • How did you approach programming each step for the challenge?
  • Why was documenting each step of your program important?
  • Why is testing your programming at each step important?

Self-Assessment:
Have students answer the following in their journals:

  • Why is checking each step of a long process one way to saw time debugging?
  • What was difficult about this challenge?
  • 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.

Teacher Support

Students will:

  • Create a program to move through a series of steps and turns.
  • Utilize motor pair in multiple ways.
  • SPIKE Prime sets
  • Devices with the SPIKE App installed.
  • Student journals

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.

CCSS ELA
SL.8.1
Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 8 topics, texts, and issues, building on others' ideas and expressing their own clearly

SL.8.4
Present claims and findings, emphasizing salient points in a focused, coherent manner with relevant evidence, sound valid reasoning, and well-chosen details; use appropriate eye contact, adequate volume, and clear pronunciation

RST.6-8.3
Follow precisely a multistep procedure when carrying out experiments, taking measurements, or performing technical tasks

L.8.6
Acquire and use accurately grade-appropriate general academic and domain-specific words and phrases; gather vocabulary knowledge when considering a word or phrase important to comprehension or expression

NGSS
MS-ETS1-4
Develop a model to generate data for iterative testing and modification of a proposed object, tool or process such that an optimal design can be achieved.