Teacher Resources: Python with Robots MS Mission 4-4

Mission 4-4: Animatronics Lesson 4 | Python with Robots MS
Mission 4-4 Lesson Plan

Animatronics Lesson 4: The Complete Project

Students play a fanfare using constants, then combine three previous programs into one complete Animatronics project.

⏰ 40-45 min 🎯 Grades 6-8 💻 CodeSpace 🤖 CodeBot 🐍 Python
View Lesson Outline
📋

Overview

Mission 4-4 is the capstone lesson of the Animatronics unit. Students learn to define and use constants - variables with ALL CAPS names that hold values that don't change during program execution. They use constants to represent musical notes and call the note() function multiple times to play a fanfare. Then, using CodeSpace's multi-program text editor, they combine code segments from their three previous lessons into one complete, working Animatronics project.

🎯 Mission Goal: Students will build a complete Animatronics program that combines LED sweeping, robot movement with sounds, and a fanfare - all triggered from a single napkin sketch design.

🎯

Learning Targets

  • I can define a constant.
  • I can use a constant as an argument in a function call.
  • I can call a function several times, with different arguments.
  • I can combine code segments from one program with code from another program.
💡

Key Concepts

  • Python doesn't have a specific designation for a constant - it is just another variable. But you can visually distinguish a constant from a variable by using ALL CAPS for its name. This can help you remember not to update the value during the program execution.
  • CodeSpace allows for several programs to be open at the same time. Using the text editor, it is easy to add code from one program into another program using copy/paste.

Assessment Opportunities

☑️

Success Criteria

  • Define a constant
  • Use a constant as an argument in a function call
  • Call the note() function multiple times to play a song
  • Combine parts of three programs into one complete project that accomplishes all the tasks on the napkin sketch
🧰

Classroom Materials

  • CodeBot
  • USB cable
  • 4 AA batteries
  • Optional: measuring stick
🌍

Real-World Applications

🛠Constants are used all the time in real-world applications - for example, minimum and maximum values, a constant temperature to maintain, or a specific number to reach.
💻Combining parts of different programs into one complete project happens in real life all the time - software teams regularly merge code from different modules into a final product.
🎪Animatronic characters at theme parks use constants to control precise motor positions, sound timings, and LED patterns - all combined into one synchronized program.
🚀

Extensions & Cross-Curricular

ExtensionUse extension ideas from Lessons 1-3, or the end-of-mission remix suggestions. A remix project follows this lesson and is another great opportunity for extensions.
Performing ArtsHave a lesson on reading sheet music. Write a program that uses constants for note frequencies and plays a recognizable song using the note() function.
Lang ArtsSupports language arts through reading instructions, guided notes, and reflection writing.
🔤

Vocabulary

Constant - A variable that holds a value that doesn't change during program execution; often designated by typing the name in ALL CAPS.
🐍

New Python Code

F4 = 349 C5 = 523
Define a constant (usually with ALL CAPS)
note(F4, 0.1) note(C5, 0.8)
Use a constant as an argument in a function call
📐

Standards

CSTA K-12 CS Standards

2-AP-10 2-AP-11 2-AP-12 2-AP-13 2-AP-14 2-AP-16 2-AP-17 2-AP-19
📄
Preparing for the Lesson
  • Decide what materials you want to use for presenting the lesson. The slides can be projected on a large screen.
  • Be familiar with the mission log assignment and the questions students will answer. Prepare the assignment to give through your LMS. There aren't many questions for this assignment - most of the work is done in CodeSpace.
  • If you have a word wall or another form of vocabulary presentation, prepare the new term: Constant.
📋
Teacher Notes
  • RECOMMENDATION: Use the slides instead of instructions in CodeSpace and CodeTrek. This is the final lesson that combines the previous programs into one complete project. The final code works the same but is in a different order from CodeTrek. Use the slides or CodeTrek, but not both.
  • Students will not start a new program for this lesson. They start with the last program (RobotMoves) and save it with a new name.
🕐

Lesson Outline

💡 Discussion Tip: You can use a variety of discussion strategies to get the most engagement. Have students write their answers before calling on anyone, use think-pair-share, or randomly select students to respond.
🗣️ Warm-Up / Hook - Slide 2

Students can write in their log first and then share, or discuss first and then write. These warm-up questions review code from Mission 4 Lesson 1.

  • Question: What lines of code pause the program and wait until a button is pressed?
  • Question: How do you define and call a function?
💻 Mission 4 Lesson 4 Activities

The Chrome browser works best, but other browsers also support CodeSpace. Each student will complete a Mission Log. Students could work in pairs through the lesson, or they can work individually.

🎶 Mission Introduction - Slides 3-4
💡 Tip: This mission is divided up into four lessons. The fourth lesson goes through the last objective and then puts all the pieces together. These slides review the task and goal. No questions in the mission log.
🎯 Objective #12 - Slides 5-15
💡 Tip: This objective has a lot of slides because they just break down the objective into several little chunks.
  • Slides 5-6: Introduce the problem. Students open the program from Lesson 3 and save it with a new name.
  • Slides 7-9: Music and notes background. Slide 10: Define a constant - students add constant definitions to their program.
  • Slide 11: Show the complete code. Slides 12-13: Call note() multiple times to complete the fanfare.
  • Slides 14-15: Move the fanfare code to the end of the program. Students run and verify the program works.
  • All mission goals will be met after Objective 12. Students can proceed to Mission 5, but they aren't done - the next slides combine all programs into one complete project. Students can stay in Mission 4 Objective 12 or move to the sandbox.
🔊 Using the Cute Robot Sounds - Slides 16-21
💡 Tip: Students fix the code so that sounds beep while the robot is spinning, not after. The time it takes the robot to sound beeps replaces the sleep() function. Students do a little math to figure out how many beeps are needed to give the robot time for spinning - use the chart in the mission log. Students may need to adjust the specific number after testing.
🤖 Animatronics: Combining Programs - Slides 22-33
💡 Tip: These slides walk students through combining code segments from Lesson 1 and Lesson 2 into this program for a complete project. Students aren't required to write anything in the Mission Log, but you can add a notes space if you want to. By the end of slide 33, students should have a fully working project.
Final Touches - Slide 34
💡 Tip: After running the complete program, students may want to improve it. Suggest lowering the delay time for sweeping LEDs - the default value of 0.5 is pretty slow. Optional: review binary numbers (Mission 3 Lesson 2) and use binary numbers to indicate guests. The 5 line sensors can count up to 15.
💡 Extensions - Slide 35: If you have time, students can do an extension. Many remix ideas are given in the end-of-mission completion message. A remix project follows this lesson in the unit, so you may want to hold off and do the remix project instead.
🆕 Optional: Mission 4 Obj. 12 Kahoot! Review

A review Kahoot! is available for this lesson - it focuses on the use of constants. Alternatively, you can use the Kahoot reviews from Lessons 1, 2, and 3.

🤝 Post-Mission Reflection

The post-mission reflection asks students to think about the programming process. Each student will likely answer differently - this is a great opportunity for a share-out.

  • You can use a cross-curricular activity as the post-mission activity.
  • Discuss real-world applications for constants and/or combining parts of things to make a new project.
  • End by collecting the Mission 4 Lesson 4 Log.