Sensors (Inputs) 1, 2

Lesson (25 mins):

Classroom Code / Project:  Inputs, Inputs + LED , Light LED Strip with Inputs

Equipment:  (1 for each Trainee) 

Skills

Keywords

What is a sensor?

The micro:bit has a bunch of built-in sensors. 

A sensor is kind of what it sounds like—it’s an electronic component that works kind of like our own senses to take in information from outside the micro:bit. 

For instance, in the same way that my ears can sense sound, the micro:bit has a microphone to sense sound. These sensors, and any other information that goes into the micro:bit (like a message over the radio or a button press), are called inputs.

How to code inputs?

Facilitator guides the students through adding the following input blocks one at a time (and showing them where the Input blocks are), uploading them to their micro:bits to test them out, and explaining how each one works. 


The full code can be found here: Inputs (also shown in picture)


Remember to use terminology keywords!

This input tells it the micro:bit to do whatever is in the code block when Button A is pressed. In this case, when button A is pressed, the micro:bit will show a smiley face on the LED matrix, wait 500 milliseconds (half a second), then clear the screen.



One of the sensors the micro:bit has built in as an accelerometer. This is an electronic component that senses movement (acceleration, specifically). The accelerometer can sense when you shake the micro:bit and use that as an input.



Another sensor the micro:bit has built in is a microphone, to sense sound. 



The 0, 1, 2 pins (facilitator should show what the “pins” refer to on the micro:bit) as well as the logo can sense touch. 


Open-Ended Exploration

Open-ended exploration of using different inputs to create outputs such as lighting an LED strip or sending a message via radio. 

Some examples can be found here: Inputs + LED, Light LED Strip with Inputs


For Part 1, we used the inputs to turn on the LED screen (the output). But we can use these inputs to trigger other outputs as well, such as turning on the LED strip or, if you’ve taken the Broadcasting course, to send messages.