< Creating Apps with Devices (micro:bit) ('23-'24)

Lesson 9: Combining Inputs and Outputs

45 minutes

Overview

In this lesson, students combine inputs and outputs across both the micro:bit and the app screen. For example, students may use dropdowns or sliders to make the LEDs on the micro:bit change. Or, students may use the buttons on the micro:bit to update elements on the screen. This lesson also extends how students use variables and if-statements to make more complex decisions based on user input. There are no new coding commands or micro:bit features in this lesson, but students are combining many elements from previous lessons in new ways.

Question of the Day: How can I use inputs and outputs from both the micro:bit and the app screen?

CSTA K-12 Computer Science Standards (2017)
    • 2-AP-11 - Create clearly named variables that represent different data types and perform operations on their values.
    • 2-AP-13 - Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
    • 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.
    • 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 inputs from app design elements to update screen elements or produce output on the micro:bit
  • Use inputs from the micro:bit to update screen elements or produce output on the micro:bit
  • Use variables and if-statements for complex user interaction

Preparation

  • Prepare a board and USB cable for each pair of students
  • (Optional) consider preparing external reference materials from previous lessons for students, such as a Word Wall or Reference Packet, that students can access.
  • 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
For the students

Teaching Guide

Warm Up (5 minutes)

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: Create a chart like the one below. Write down all the design elements or micro:bit components that go in each box

Share: Have students share with a neighbor, then with the whole class. As students share, fill in the chart in the front of the room

Discussion Goal: This prompt synthesizes the different inputs and outputs students have been learning about throughout the unit so far. A complete list is given in the picture below (click to enlarge). Help students uncover each item in the chart.

Remarks

We’ve seen a lot of different ways to get input from the user, and a lot of choices for how we can display output to the user. In today’s lesson, we’re going to see how we can combine these different forms of input and output to make more complex apps.

Video: Show students the Input / Output Devices video.

Teaching Tip

To encourage active engagement and reflection, use one or more of the strategies discussed in the Guide to Curriculum Videos.

Activity (35 minutes)

Transition: Send students to Code Studio

Teaching Tip

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: Student responses may include:

  • The screen is using a dropdown menu and a getProperty block for input to see whether the LED should turn on or off
  • The screen is using a label and a setText block for output to display whether the light is on or off
  • The micro:bit is using the buttons and an onBoardEvent block for input to turn on or off the lights
  • The micro:bit is using the ledScreen blocks as output to turn on the lights

Students will also need their micro:bits for this level. If student’s boards aren’t working, have them visit https://studio.code.org/maker/setup.

Assessment Opportunity

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: What’s an example of a device you’ve seen that combines inputs and outputs between an app and a device? For example, you might press buttons on a device and then something changes on the app.

Discussion Goal: This prompt foreshadows the project introduced tomorrow, where students develop their own projects that explore human/device interaction. Students may think of examples where they enter information on a keypad or controller and something changes on a screen. Or, students may think of examples where they press buttons on a touchscreen and something physically happens with a device, such as complex vending machines that select items based on screen inputs.

Creative Commons License (CC BY-NC-SA 4.0).

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.