Lesson 11: Board Sensors
45 minutes
Overview
In this lesson, students explore how the two sensors (light and temperature) can be used to write programs that respond to changes in the environment. The use of these sensors marks a transition in terms of how users interact with a program. By using sensors as an input, the user of an app doesn't have to directly interact with it at all or may interact without actually realizing they are doing so.
Question of the Day: How can I use sensors to detect changes in the environment?
Standards
AP - Algorithms & Programming
- 2-AP-11 - Create clearly named variables that represent different data types and perform operations on their values.
- 2-AP-12 - Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.
- 2-AP-13 - Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
- 2-AP-16 - Incorporate existing code, media, and libraries into original programs, and give attribution.
- 2-AP-17 - Systematically test and refine programs using a range of test cases.
- 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.
CS - Computing Systems
- 2-CS-01 - Recommend improvements to the design of computing devices, based on an analysis of how users interact with the devices.
- 2-CS-02 - Design projects that combine hardware and software components to collect and exchange data.
- 2-CS-03 - Systematically identify and fix problems with computing devices and their components.
Agenda
Objectives
Students will be able to:
- Develop programs that respond to sensor input
- Scale a range of numbers to meet a specific need
Preparation
- Prepare a board and USB cable for each pair of students
- Consider having some flashlights or other light sources on hand for testing the light sensor
- Check the "Teacher's Lounge" forum for verified teachers to find additional strategies or resources shared by fellow teachers
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the teachers
- Board Sensors - Slides
For the students
- Data & Change Events - Resource
- Setting Sensor Scale - Resource
- The micro:bit Sensors - Resource
Teaching Guide
Warm Up (5 minutes)
Distribute: Pass out micro:bits to each pair of students
Prompt: Humans have 5 senses - touch, taste, sight, smell, and hearing. Which of these senses do you think the micro:bit has? Are there any that you think the micro:bit has that we don’t?
As students consider this question, encourage them to look at the markings on the micro:bit for clues (for example: there are eye and ear icons on the micro:bit that can give clues)
Share Out: Have students share with a neighbor, then lead a full-class discussion. Take notes at the front of the room.
Discussion Goal: Using the markings on the micro:bit, students may predict that there are visual and auditory sensors, but they might not be able to describe exactly what they do - for example, does the visual sensor “see” objects, or detect distance, or detect colors, or detect light? Students may also predict that there is a temperature sensor based on the thermometer icon on the micro:bit. Students may also predict sensors that the micro:bit does not have, like humidity or heart-beat sensors, but it’s fine to list them for now as part of the brainstorm discussion.
Remarks
Today we’re going to learn about the different sensors that the micro:bit has and how they can be used for input.
Question of the Day: How can I use sensors to detect changes in the environment?
Activity (35 minutes)
Transition: Send students to Code Studio
Guide to Programming Levels: Additional guidance for programming levels is provided in the Guide to Programming Levels. This document includes strategies and best-practices for facilitating programming levels with students.
Troubleshooting Devices: If student devices aren't able to connect, they can click the Help and Tips tab and then access the Maker Setup page (click the image to see more). This will let them re-reconnect their board to App Lab.
If students continue to have issues, refer to the Troubleshooting section of our Maker Support Article
Discussion Goal: There are two sensors on the micro:bit: a light sensor and a temperature sensor. Encourage students to relate the sensors to their own senses and interact with the micro:bit that way - for example, what happens when we show or hide things from the micro:bit?
Through experimentation, students should notice that the minimum value is 0 and the maximum value is 255. Students may also notice that one sensor (temperature) doesn't seem to change very much.
Discussion Goal: Students should notice two new blocks in this code - setScale()
and onBoardEvent
which refers to the lightSensor
. Students might predict that something will change on the screen related to the light sensor, but they may not be sure how the board event works. They may notice that setScale
includes the value 450 which is the height of the screen. Once students run the program and see the emoji moving up and down on the screen, they may be able to make the connection between the scale value and the screen height. It's okay if students still aren't sure about the new board event, since this is introduced in the following level.
Formative Assessment: This level can be used as a formative assessment. A rubric is provided in the level, and written feedback can be given to students. Click here to learn more about giving feedback to students.
Wrap Up (5 minutes)
Sensors All Around
Journal: Considering all of the computing devices that you interact with on a regular basis, write down as many potential sensors as you can. What type of sensor do you think you interact with the most?
Discussion Goal: Students may repeat ideas from the warm-up discussion, but encourage them to make connections to other real-world devices. Emphasize that they can think of situations where devices must account for a range of values like we saw with these sensors.
This work is available under a Creative Commons License (CC BY-NC-SA 4.0).
If you are interested in licensing Code.org materials for commercial purposes contact us.