Lesson 4: Board Events
45 minutes
Overview
This lesson transitions students from considering the Circuit Playground as strictly an output device and instead introduces the buttons and toggle switches as tools for input. Starting with the hardware buttons and switch, students learn to use onBoardEvent()
, analogously to onEvent()
, in order to take input from their Circuit Playgrounds.
Question of the Day: How can the user interact with the circuit playground for input?
Assessment Opportunities
-
Use a board event handler to control buttons on the circuit playground
Code Studio: see rubric on the assessment level
-
Use a board event handler to control the toggle switch on the circuit playground
Code Studio: see rubric on the assessment level
Standards
AP - Algorithms & Programming
- 2-AP-13 - Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
- 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:
- Use a board event handler to control buttons on the circuit playground
- Use a board event handler to control the toggle switch on the circuit playground
Preparation
- Prepare a board and USB cable for each pair of students
- 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 Events - Slides
For the students
- Board Events - Resource
- Physical Input - Resource
Vocabulary
- Input - the information computers get from users, devices, or other computers
Teaching Guide
Warm Up (5 minutes)
Board Inspection: Inputs
Distribute: Pass out a board and USB cable to each pair of students. Let students know that they should not yet plug the boards in.
Prompt: Ask pairs to spend one minute looking over the board, focusing on potential input devices. Based on what you already know about this board, how do you think you might use it to get input?
Share: Have groups share back their thoughts to the whole group, keeping track of ideas on the board. Push students to support their ideas with evidence from reviewing the board, but don't worry about ensuring correctness at this point.
Discussion Goal: Students will probably notice the buttons on the circuit playground. Students may also notice the small slider in the middle of the circuit playground that toggles back and forth. If students don’t address these, be sure to bring them up. Students may also ask about the small pads on the outer ring of the circuit playground, or they may notice the eye / ear / temperature icons on the circuit playground for the different sensors. Both of these are types of inputs that are discussed in later lessons - if students bring these up, acknowledge them but also let students know we’ll investigate these more in future lessons.
Remarks
So far, we've only learned how to control the output from the Circuit Playground. Today, we'll learn how to use the inputs on the Circuit Playground, like the buttons and toggle switch. Inputs are how the device gets information from the user.
Vocabulary:
- Input: the information computers get from users, devices, or other computers
Activity (35 minutes)
Transition: Send students to Code Studio
Guide to Programming Levels: Additional guidance for programming levels is provided in the CSD Guide to Programming Levels. This document includes strategies and best-practices for facilitating programming levels with students.
This code uses an event to detect user input, but it waits for an event on the circuit playground instead of the screen. When students run the code, nothing will happen until they press the left button on their circuit playground. Once they do, the red LED will light up. If student’s boards aren’t working, have them press the Setup button in the maker app or visit https://studio.code.org/maker/setup on a Chromebook.
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)
Journal 3-2-1
- What are three types of board events you have seen so far?
- Describe two different situations and how they would need two different events.
- What's one other event you haven't learned yet, but you think might exist?
Discussion Goal: Students should make reasonable choices for when one board event might be better than another. You may want to have a short class discussion before or after this journal prompt to highlight the advantages and disadvantages of each event type.
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.