Brain DeCoded with CodeX - Mission 3, Objective 3: Your Brain on Sunshine

Mission 3 · Objective 3 Lesson Plan

Your Brain on Sunshine

Students code a simulation that uses the CodeX light sensor to model what sunshine and time in nature do to the brain, using flashlights and their own hands to change the light.

⏱ 45-70 min 🎯 Grades 8-12+ 💻 CodeSpace 🎮 CodeX ☀️ Light Sensor
View Lesson Outline
📋

Overview

Objective 2 simulated a full day of activities. This one zooms in on a single variable, light. Students build sunshine, a program that reads the CodeX's built-in light sensor and models what more sun, and less of it, does to brain function.

The input is physical. Students shine a flashlight on the sensor to add light and cover it with a hand to take it away, so the numbers on screen respond to something they are doing in the room. Six events are listed on the Activity Guide, and students can run them in any order and as many times as they want.

The code introduces a small set of built-in math functions, abs(), int(), and min(), each doing a specific job with the sensor reading.

🎯 Project Goal: Students add code to a program that simulates the effects sunshine and nature have on the brain.

🎯

Learning Targets

  • I can explain how sunshine and being in nature affect brain function.
  • I can code and run a sunshine and nature walk simulation.
  • I can observe and record the results of sunshine and nature walks on brain function.
💡

Key Concepts

  • Increased sunshine and nature walks have a positive effect on brain function.
  • Lack of sun can negatively affect brain function.
  • Students use a flashlight, or another light source, to simulate sunshine.
✅

Assessment Opportunities

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

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
  • ▸Flashlights, or another light source. A phone flashlight works.
🚀

Extensions & Cross-Curricular

ExtensionStudents with programming experience can adjust the light reading interval in sun_interval(), or modify the code in sunlight().
MathThe program uses several built-in math functions, like abs(), int(), 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.
🐍

New Python Code

▾
reading = light.read()Read the light sensor and return its value
if abs(reading - normal) > 350:The abs() function returns the absolute value of the argument. It can be used to detect a change, either positive or negative.
mm = int(m_percent/100 * 255)The int() function returns the value of the calculation as an integer.
m_percent = min(mm, 100)The min() function returns the smaller value
📐

Standards

▾

Physical Science

HS-PS3-1
📝
Preparing for the Lesson
  • Run sunshine yourself first, and try the flashlight and hand-cover inputs so you know what range of readings your room produces.
  • Gather light sources. Flashlights work, and so do phone flashlights if your school allows them. You do not need one per student, groups can share.
  • Decide how students get the Activity Guide. You can print a copy for each student or assign it digitally. Students record their six events on it, so they need it before they start.
  • Check the lighting in your room. A classroom right next to a bank of windows behaves differently from one with the blinds down, and that baseline affects every reading.
  • Read the Hints in the objective. They carry extra information about sunlight that is worth reviewing with students.

🧑‍🏫
Teacher Notes
  • The Hints include additional information about sunlight. You can review them with students.
  • The simulation uses the CodeX light sensor. It is built in, so students do not need to do anything extra to connect it. The amount of light shining on the light sensor is returned as a value.
  • Students can use flashlights to add light, and cover the sensor with their hands to remove light.
  • Students should follow the instructions on the Activity Guide to conduct the simulation. Six events are listed. They can be done in any order and repeated as often as students want.
  • Students can repeat the simulation by starting it over, like going to a new day.
  • 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

Start with something students have felt themselves.

  • Ask: "How do you feel after a week of gray, rainy days compared to a bright one? Is that real, or is it in your head?"
  • Ask: "If we wanted to measure sunshine with the CodeX, what would we need it to sense?"
Teaching tip: The second question lands the light sensor without you having to introduce it. Students almost always get there on their own, and then the code makes sense before they write it.
💻Build the Simulation

Students add code to sunshine.

  1. Students work through the CodeTrek steps, adding code to sunshine.
  2. Stop on the math functions as they appear. abs() detects a change in either direction, int() drops the decimal, and min() caps a value.
  3. Review the Hints on sunlight with students at whatever point fits your pacing.
  4. Confirm the program runs without errors before students start collecting data.
Teaching tip: Ask why the code uses abs() instead of just checking whether the reading went up. Students who can answer that understand what the program is actually watching for.
🔦Run & Record

Students run the six events and record results on the Activity Guide.

  1. Students work through the six events, in any order they like.
  2. Flashlight on the sensor adds light. A hand over the sensor takes it away.
  3. Events can be repeated as often as students want, and the simulation can be restarted for a fresh day.
  4. Students record what each event does to the levels.
Teaching tip: Watch for students holding the flashlight an inch from the sensor and pinning the reading at maximum every time. Ask them to try it from a distance too, so they get a range instead of one value.
✏️Wrap-up & Review

Bring it back to the brain.

  • Compare results across the room. Which events had the biggest effect?
  • Ask: "What does this simulation say about someone who spends the whole day indoors?"
  • Ask: "The sensor measures light. What does sunshine do for the brain that a flashlight does not?"
  • Collect the Activity Guides.
Teaching tip: That last question is where the model breaks down honestly, and it is worth saying so. A light sensor is a stand-in, not the real thing, and students naming the gap is a sign the concept landed.