Brain DeCoded with CodeX - Mission 2, Objective 3: Code a Neuron

Mission 2 · Objective 3 Lesson Plan

Code a Neuron

Students build a working neuron in code, with the CodeX standing in for the dendrites, soma, and axon they have been studying.

⏱ 45-70 min 🎯 Grades 8-12+ 💻 CodeSpace 🎮 CodeX 🐍 Python
View Lesson Outline
📋

Overview

Students have read about the neuron and stood in a human chain acting like one. Now they code it. The program neuron_sim maps each part of the neuron onto the CodeX, so the parts students already know get a physical home: something to receive the signal, something to process it, and something to respond.

The one setup step to watch for is the custom module. The program imports functions from a separate file, and that file has to be opened and run once so it loads onto the CodeX. After that it stays on the device, and students never have to think about it again. Students who skip that step get import errors, so it is worth doing as a class.

🎯 Project Goal: Students add code to a program that simulates a neuron.

🎯

Learning Targets

  • I can write a program that models a neuron.
  • I can explain the phases of the program and each part of the neuron it represents.
💡

Key Concepts

  • The text reviews the parts of a neuron while explaining how it will be represented with the CodeX device.
  • The CodeX program uses a custom module, which is a file students need to open and run first. This loads the file onto the CodeX. Once it is there, it will stay there and doesn't need to be loaded again.
✅

Assessment Opportunities

  • Turn in the Activity Guide.
  • Complete the program neuron_sim.
☑

Success Criteria

  • Complete the CodeTrek steps
  • Program runs correctly without errors
  • Activity Guide is completed
📂

Digital Resources

🧰

Classroom Materials

  • ▸CodeX device and USB cable, one per student or pair
  • ▸Laptop/computer with Chrome browser
🚀

Extensions & Cross-Curricular

ExtensionStudents who are familiar with coding can adjust some values in the code: the weighted randint range in send_signal(), any value added to or subtracted from strength, and the value added to start_time.
MathStudents run their program several times and collect data. The data can be made into a graph and compared with other students' data. Use the graph to make inferences or draw conclusions, such as do students get faster with more trials? Develop an equation to describe the data.
🔢

Vocabulary

▾
Custom Module:a file that contains a lot of Python code that will be used in the program. Once you run the file, it stays on the CodeX and its functions can be used anytime after being imported.
🐍

New Python Code

▾
from neurons import *Import the custom file to access its functions
send_signal()
processing()
responding()
Function call
breakExits the loop to stop the program
📐

Standards

▾

Computer Science

9-12.AP.16
📝
Preparing for the Lesson
  • Decide how students get the Activity Guide. You can print a copy for each student or assign it digitally.
  • Run the program yourself first, including the custom module step, so you know what a working neuron_sim looks and sounds like on the CodeX.
  • Read the Hints in the objective. They carry extra detail on neurons and custom modules that is worth reviewing with the class.
  • Have CodeX devices and cables ready, and plan for the wider time range. This objective can run 45 minutes or closer to 70 depending on how much coding experience your students have.

🧑‍🏫
Teacher Notes
  • The Objective has an Activity Guide for students. You can print the guide for each student or assign it digitally.
  • The Hints give additional information about neurons and custom modules. You may want to emphasize this or review with the students.
  • The custom module file must be opened and run once before the main program will work. It then stays on the CodeX. Most errors in this objective trace back to that step being skipped.
  • Extensions and cross-curricular projects are included to enhance the concepts in the objective. You can use the extensions to extend students' learning.
🗺️

Lesson Outline

🗣️Warm-up / Hook

Connect the unplugged chain to the device on the desk.

  • Ask: "In our simulation, you were the neuron. If the CodeX had to play your part, what would it use to receive a signal, and what would it use to respond?"
  • Ask: "When you import something in Python, where does that code actually live?"
Teaching tip: Take the first question literally and let students name buttons, the screen, sound, and lights. Mapping neuron parts onto real CodeX hardware is exactly what the objective's text does next.
📖Lesson Activities

Review the model, then get the custom module loaded before anyone starts coding.

  1. Students read the objective text, which reviews the parts of a neuron and shows how each one is represented on the CodeX.
  2. Introduce the custom module. Explain that the file holds Python code the program needs, and that opening and running it once copies it onto the CodeX.
  3. As a class, open and run the module file. Confirm every student got it onto their device before moving on.
  4. Hand out or assign the Activity Guide and point students at the CodeTrek steps.
Teaching tip: Do the module step together, all at once. It takes two minutes as a class and saves you troubleshooting import errors one student at a time for the rest of the period.
💻Student Work Time

Students build out neuron_sim and fill in the Activity Guide as they go.

  1. Students work through the CodeTrek steps, adding code to neuron_sim.
  2. Students call send_signal(), processing(), and responding(), and use break to exit the loop and stop the program.
  3. Students run the program, confirm it works without errors, and complete the Activity Guide.
  4. Fast finishers move to the extension and start adjusting values in the code.
Teaching tip: As students test, ask them to name which phase of the program is running and which part of the neuron it stands for. That is the second learning target, and it is easier to check out loud than on paper.
✏️Wrap-up & Review

Close on the mapping between code and biology.

  • Quick share: walk through the phases of neuron_sim and name the neuron part each one represents.
  • Ask: "What did the custom module save you from having to write yourself?"
  • Collect the Activity Guides.
Teaching tip: If you have time for the math extension, have students save their run data today. Collecting it while the program is fresh is easier than coming back to it later.