Lesson 16: Physical Inputs and Buttons
90 minutes
Overview
In this lesson, students learn how to connect external wires to create input events when the wires touch, simulating a button press. Students learn to use code to recognize these external button events to make changes to their app. This allows students to create more flexible devices that mimic real-world products. This lesson requires several external materials, as well as safety protocols to ensure students don’t accidentally damage their micro:bit.
Question of the Day: How can I use external buttons to create physical prototypes?
Standards
AP - Algorithms & Programming
- 2-AP-10 - Use flowcharts and/or pseudocode to address complex problems as algorithms.
- 2-AP-11 - Create clearly named variables that represent different data types and perform operations on their values.
- 2-AP-14 - Create procedures with parameters to organize code and make it easier to reuse.
- 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.
CS - Computing Systems
- 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.
IC - Impacts of Computing
- 2-IC-21 - Discuss issues of bias and accessibility in the design of existing technologies.
Agenda
Objectives
Students will be able to:
- Create and debug a circuit with a button
- Create prototype devices that use an external button for input
Preparation
- Prepare circuit wiring materials, such as:
- Alligator clip wires
- LEDs
- Other conductive material (wire, paper clips, foil, etc)
- (optional) Buttons or switches
- 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
- Physical Inputs and Buttons - Slides
For the students
- External Buttons on a micro:bit - Resource
Introduced Code
Teaching Guide
Warm Up (5 minutes)
Prompt: Yesterday we used electricity to create a circuit to light up an LED. Today, we’re going to explore how to use electricity to represent a button press that we can use for input. What do you think that circuit will look like? What materials do you think we’ll need?
Discussion Goal: This discussion asks students to make connections between the electrical knowledge they developed in the last lesson and make connections to today’s lesson. Students might suggest that they will need to connect wires to one of the pins and a GND pin in order to represent the flow of electricity. They may be less sure about what happens in between those two pins, and may suggest different materials that we will need. Keep track of their responses, but don’t validate any responses as correct or incorrect yet. Instead, students will discover how buttons work in the first level in Code Studio
Activity (80 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
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)
Prompt: Think back to the list of devices you wish you could develop and how people would use it. Using what we’ve learned in the last few lessons, describe with more details how you could start to create a device like that. How would you connect the wires? What external components would you use?
Discussion Goal: This prompt asks students to remember their responses to the warm-up from the previous lesson. Based on what they’ve learned, students can hopefully describe their devices in more detail, explaining how they would use wires and LEDs to create the effects they’re imagining. Encourage students to share their ideas with each other, which will help prepare students for the project in the next lesson.
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.