← Circuits with the micro:bit

Circuits with the micro:bit: recap

For after the lessons: one card per lesson, to check what you remember. Answer each question in your head or on paper first, then check it. Nothing here is marked.

Lighting an LED

1. A complete loop

Try firstPin 0 is on, every wire is clipped, and the LED is dark. Give two possible reasons.

Check your answer

The LED is the wrong way round, or a wire isn't really connected (the loop is broken). Also possible: the pin isn't actually on.

Current only flows around a complete loop: out of pin 0, through the resistor and the LED, and back into the micro:bit at GND. Break the loop anywhere (a wire off, or the LED the wrong way round) and the current stops everywhere at once. Switching pin 0 off (0 V) stops it too: nothing pushes the current round.

A complete loop: pin 0, a resistor, an LED and back to GND.
A complete loop: pin 0, a resistor, an LED and back to GND.
Current needs a complete loop · Sound on for the voiceover
Open the lesson →

2. Why the resistor

Try firstWith a 330 Ω resistor and a 2 V LED on a 3.3 V pin, how much current flows? Is it safe?

Check your answer

1.3 ÷ 330 ≈ 0.0039 A ≈ 3.9 mA: safe, under 20 mA.

With no resistor, far too much current flows and the LED is damaged. A resistor limits the current. Ohm's law: current = voltage ÷ resistance. The LED uses about 2 V of the pin's 3.3 V, leaving 1.3 V across the resistor, so 220 Ω gives 1.3 ÷ 220 ≈ 0.006 A = 6 mA. More ohms, less current. In a single loop the current is the same everywhere, so the resistor works before or after the LED.

No resistor: about 100 mA, five times what the LED can take.
No resistor: about 100 mA, five times what the LED can take.
The resistor limits the current · Sound on for the voiceover
Open the lesson →

Reading inputs

3. A button is an input

Try firstWhy does a button wired from 3V to a pin need a resistor from the pin to GND?

Check your answer

So the pin is held at 0 V (reads 0) when the button is up. Without it the pin floats and reads 0 or 1 at random.

A pin set as an input reads the voltage on it: digital read gives 1 for 3.3 V and 0 for 0 V. A button joins pin 0 to 3V only while it is held. When it is up, a pull-down resistor joins the pin to GND, so it reads 0. Without one the pin is joined to nothing, floats, and reads 0 or 1 at random.

A button from 3V to pin 0, and a pull-down resistor from pin 0 to GND.
A button from 3V to pin 0, and a pull-down resistor from pin 0 to GND.
A button on a pin · Sound on for the voiceover
Open the lesson →

4. Sensors that vary

Try firstPin 0 reads 256. Roughly how many volts are on it, and what fraction of the way up is the knob?

Check your answer

About a quarter of the way up, so about 0.83 V (256 ÷ 1023 × 3.3).

Analog read turns the voltage on a pin, 0 to 3.3 V, into a number from 0 to 1023: halfway (1.65 V) reads about 512. A knob or a light sensor in a divider changes the voltage, so the number changes. The number is a scale, not the volts. A program compares it with a threshold to decide, such as switching lights on below 300.

A knob halfway: 1.65 V on pin 0, which analog read gives as 512.
A knob halfway: 1.65 V on pin 0, which analog read gives as 512.
From volts to a number · Sound on for the voiceover
Open the lesson →