Brain DeCoded with CodeX - Mission 3, Objective 2: Mood and Memory

Mission 3 · Objective 2 Lesson Plan

Mood and Memory

Students add code to a simulation that models how five everyday activities move dopamine and serotonin levels, then run it enough times to see the patterns.

⏱ 45-70 min 🎯 Grades 8-12+ 💻 CodeSpace 🎮 CodeX 💡 NeoPixel Ring
View Lesson Outline
📋

Overview

Objective 1 was the reading. This is where students put it to work. They add code to brain_sim, a program that simulates a day's worth of activities and tracks what each one does to dopamine and serotonin levels.

There are five daily activities in the simulation, and they do not produce the same result every time, which is the point. Students run each scenario several times, record what happens, and start seeing patterns instead of single outcomes. Exercise is modeled with the CodeX's built-in accelerometer, so the harder a student shakes the device, the more exercise the simulation registers.

This objective also introduces a few Python tools students will keep using: lists of strings, random integers, and floor division.

🎯 Project Goal: Students add code to a program that simulates dopamine and serotonin effects on daily activities.

🎯

Learning Targets

  • I can add code to a program.
  • I can run a simulation of daily activities.
  • I can observe and record the results of daily activities on brain function.
💡

Key Concepts

  • A variety of daily activities can affect brain function.
  • This activity uses the CodeX device's built-in accelerometer.
✅

Assessment Opportunities

  • Turn in the Activity Guide.
  • Complete the program brain_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
  • ▸Laptop/computer with Chrome browser
  • ▸NeoPixel Ring, from the peripherals kit
🚀

Extensions & Cross-Curricular

ExtensionStudents with programming experience can add to the life events. Positive events need to be grouped together and negative events together, and they will also need to adjust the value index is compared to in event().
ExtensionStudents can adjust the values in exercise() to vary the amount returned, or the number of shakes for each branch.
MathThe program uses several built-in math functions, like abs(), int(), round() and min(). Discuss these functions, their differences, and when each one would be used.
MathLook through the adjust_levels() function. Recreate it on paper and go through the calculations with data.
🔤

Vocabulary

▾
Dopamine:a neuromodulator that involves movement, memory, motivation, mood and learning.
Serotonin:a neuromodulator that influences learning, memory and happiness. It also regulates sleep.
🐍

New Python Code

▾
life_events = ['Spend time', 'Listen to music']Define a list of strings
index = random.randint(0, 9)Generate a random integer, including 0 and 9
s = s + points//2// is floor, or integer, division, returning the integer only, no rounding
📐

Standards

▾

Computer Science

9-12.AP.14

Health

5.2M

Science & Engineering Practices

Constructing Explanations and Designing Solutions

Mathematics

N-Q.1-3
📝
Preparing for the Lesson
  • Run brain_sim yourself first. Work through all five activities a few times so you know what the outputs look like before students start asking why their numbers changed.
  • Decide how students get the Activity Guide. You can print a copy for each student or assign it digitally. Students record their simulation results on it, so they need it in hand before they run the program.
  • Have the NeoPixel Rings out and ready. Nothing needs to be wired for the accelerometer, that is built into the CodeX.
  • Set expectations for the shaking. This objective involves students shaking their devices at their desks, so decide up front how vigorous is acceptable in your room.
  • Look over the adjust_levels() function if you plan to use the math extensions. It is the clearest place in the program to connect the code to arithmetic students already know.

🧑‍🏫
Teacher Notes
  • The simulation uses the CodeX accelerometer as a form of exercise. It is built in, so students do not need to do anything extra to connect it. The amount of shaking sets the value returned by the accelerometer.
  • Students should follow the instructions on the Activity Guide to conduct the simulation. There are five different daily activities, and they can produce different results each time the button is pressed, so students should try each scenario several times.
  • Students can repeat the simulation by starting it over, like going to a new day.
  • The randomness is the lesson, not a bug. Students who run an activity once and record that as "the answer" have missed the point. Push them to run each one several times and look at the range.
  • 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 yesterday's reading to today's simulation.

  • Ask: "Name one thing you did yesterday that changed your mood. Do you think it would do the same thing every single time?"
  • Ask: "If dopamine and serotonin affect motivation, memory and sleep, what would you expect exercise to do to them?"
Teaching tip: Write a few student predictions on the board before anyone runs the program. Comparing predictions against simulation results at the end is far more interesting than just reading the numbers.
💻Build the Simulation

Students add code to brain_sim.

  1. Students work through the CodeTrek steps, adding code to brain_sim.
  2. Point out the new pieces as they come up: the list of strings in life_events, the random integer from random.randint(), and floor division with //.
  3. Confirm the program runs without errors before students start collecting data.
Teaching tip: Floor division is the one that trips students up. A quick side-by-side on the board of 7/2 and 7//2 clears it up faster than an explanation does.
🔬Run & Record

Students run the simulation and record results on the Activity Guide.

  1. Students work through all five daily activities, following the Activity Guide.
  2. Each activity gets run several times. Results vary from run to run, so one attempt is not enough to see the pattern.
  3. For the exercise activity, students shake the CodeX. More shaking returns a higher value from the accelerometer.
  4. Students can restart the simulation to run a fresh day.
Teaching tip: Have students record every run, not just the interesting ones. When they graph or compare their data later, the boring runs are what make the pattern visible.
✏️Wrap-up & Review

Turn the data back into the science.

  • Compare results across the room. Which activities raised levels most consistently? Which were unpredictable?
  • Go back to the warm-up predictions. Which held up?
  • Ask: "The simulation is a model. What does it get right about real life, and where does it fall short?"
  • Collect the Activity Guides.
Teaching tip: That last question is the science and engineering practices standard in plain language. Students evaluating the limits of their own model is exactly what the standard is asking for.