Lesson 2 of 7
Inputs & Sensors
Learn how devices detect buttons, light, temperature, distance, movement and more.
Learn it
Sensors turn real-world information into numbers that a computer can understand.
Digital inputs have only two states, like a light switch: on or off, pressed or not pressed.
Analog inputs can have many values, like a dimmer switch or a temperature reading.
Key terms
- Digital Input
- An input that has only two possible states, such as on/off or pressed/released.
- Analog Input
- An input that can take a continuous range of values, such as brightness or temperature.
- ADC
- Analog-to-Digital Converter: a circuit that turns analog voltages into digital numbers.
- Accelerometer
- A sensor that measures acceleration, often used to detect tilt, shake or orientation.
Sensor Hunt
Look at the sensors you probably own.
- 1Phone screen: A capacitive touch sensor detects your finger by measuring tiny electrical changes.
- 2Fitness tracker: An accelerometer and heart-rate sensor measure movement and blood flow.
- 3Car parking sensor: An ultrasonic sensor sends out sound pulses and listens for echoes.
- 4Game controller: Analog thumbsticks report continuous position values, not just on/off.
Reading a micro:bit Temperature Sensor
pythonfrom microbit import *
while True:
temp = temperature()
display.scroll(str(temp) + 'C')
sleep(1000)The micro:bit's processor has a built-in temperature sensor. This program reads it once per second and scrolls the value on the LED display.
Try it
Match each sensor to what it measures.
Challenge
You are building a plant-monitoring device. Which three sensors would be most useful, and what would each tell you?
Pick whichever way suits you — every mode earns the same bonus XP.
Write at least 40 more characters to submit.
Mark your own work
Guided walkthrough — 0/5 clues revealed
- Clue 1 locked — reveal it only if you get stuck.
- Clue 2 locked — reveal it only if you get stuck.
- Clue 3 locked — reveal it only if you get stuck.
- Clue 4 locked — reveal it only if you get stuck.
- Clue 5 locked — reveal it only if you get stuck.
Each clue costs 3 XP (never below 14 XP). You'd earn 28 XP right now.
Extension: Explain whether each chosen sensor is digital or analog, and why that matters.