Brain DeCoded with CodeX - Mission 3, Objective 2: Mood and Memory
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.
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
index is compared to in event().
exercise() to vary the amount returned, or the number of shakes for each branch.
abs(), int(), round() and min(). Discuss these functions, their differences, and when each one would be used.
adjust_levels() function. Recreate it on paper and go through the calculations with data.
🔤
Vocabulary
▾
🐍
New Python Code
▾
// is floor, or integer, division, returning the integer only, no rounding
📐
Standards
▾
Computer Science
Health
Science & Engineering Practices
Mathematics
- 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.
- 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
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?"
Students add code to brain_sim.
- Students work through the CodeTrek steps, adding code to brain_sim.
-
Point out the new pieces as they come up: the list of strings in
life_events, the random integer fromrandom.randint(), and floor division with//. - Confirm the program runs without errors before students start collecting data.
Students run the simulation and record results on the Activity Guide.
- Students work through all five daily activities, following the Activity Guide.
- Each activity gets run several times. Results vary from run to run, so one attempt is not enough to see the pattern.
- For the exercise activity, students shake the CodeX. More shaking returns a higher value from the accelerometer.
- Students can restart the simulation to run a fresh day.
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.