One-sentence summary
The pins along the bottom edge of the micro:bit are connection points that let us attach outside parts such as LEDs, buzzers, or buttons, and write or read digital and analog signals to and from them.
Why does it matter?
So far you have worked with the parts built into the micro:bit itself: the LED display, the A and B buttons, the accelerometer, light and temperature sensing, and the radio. But a real robot or project usually reaches beyond the board too: a bell needs to ring, a separate LED needs to light up, or an external button needs to be pressed.
This is where the pins come in. The metal strips along the bottom of the board are gateways that connect the micro:bit to the outside world. You can use a pin like an "output" to send a signal out, or like an "input" to read a signal coming in.
Learning about pins lets you combine the LEDs, buzzers, and buttons from the electronics lessons with a programmable board. You build the circuit and control it with code at the same time. This is the first step behind many ideas, from a toy alarm to a wearable project.
What are the edge pins?
Along the bottom edge of the micro:bit you can see gold-colored metal strips. These are called pins (connection points). A pin is like a gateway that lets electricity flow into and out of the board.
The five largest and most-used pins are:
| Pin | Name | What it does |
|---|---|---|
| 0 | Pin 0 | Input/output; general purpose |
| 1 | Pin 1 | Input/output; general purpose |
| 2 | Pin 2 | Input/output; general purpose |
| 3V | Power (+) | Gives a positive supply to a part |
| GND | Ground (−) | The negative end of the circuit |
Pins 0, 1, and 2 have large holes, so a crocodile clip attaches to them easily. You can use them both to send a signal out (output) and to read a signal in (input).
The 3V pin gives positive power, and GND is the negative end. To run an outside part, you usually connect a signal pin (0, 1, or 2) together with one of these.
Connecting with crocodile clips
The easiest way to reach the large pins is to use crocodile clips (cables with jaw-shaped clips at the ends). You clip the jaw onto the metal around the pin's big hole and connect the other end to your part. No soldering is needed, which makes it perfect for beginners.
Example: Think of a flashlight. Inside it there are batteries, a switch, and a bulb, all joined by wires. A micro:bit project uses the same idea, but instead of wires we use crocodile clips, and instead of a switch we use code.
Example: When you plug headphones into a phone, sound flows from the phone to the headphones. A pin is a similar gateway, letting a signal flow from the micro:bit to the outside part.
Digital and analog: writing and reading
There are two basic ways to use a pin: writing (sending a signal out) and reading (taking a signal in). The signal itself can also come in two kinds: digital and analog.
Digital: on or off
A digital signal takes only two values: 1 (on, electricity present) or 0 (off, no electricity). Think of a light switch; it is either on or off, with nothing in between.
- Digital write: Write 1 to pin 0 and it turns on, so a connected LED lights up. Write 0 and it turns off.
- Digital read: Connect a button to pin 0 and you read whether it is pressed as 1 or 0.
Analog: a range of values
An analog signal can take many values, from 0 to 1023. Think of a dimmer switch; you can raise or lower a light little by little.
- Analog write: Write a value from 0 to 1023 to a pin to set an LED's brightness or a buzzer's tone gradually.
- Analog read: Connect a light sensor or a potentiometer and read the incoming value between 0 and 1023.
Example: A radio's volume knob is analog; you turn the sound up bit by bit. The lamp in a fridge door is digital; it lights when the door opens and goes off when it closes. Pins carry these same two ideas.
Example project: A sound on pin 0 with a buzzer
Now let us put it together. We will connect a buzzer to pin 0 and make the micro:bit play sound. To use the micro:bit's music blocks, it is traditional to connect the buzzer to pin 0.
Connection plan:
Buzzer connection (crocodile clips)
Buzzer (+) ----> micro:bit Pin 0
Buzzer (-) ----> micro:bit GND
The program as a MakeCode block sequence:
on start
set audio output pin to "P0"
forever
if <button A is pressed> then
play note "C" for 1 beat
if <button B is pressed> then
play melody "ba ding"
The same idea in MicroPython:
from microbit import *
import music
while True:
if button_a.is_pressed():
music.pitch(262, 500) # note C, 500 ms
elif button_b.is_pressed():
music.play(music.BA_DING)
In MicroPython the music module sends sound out of pin 0 by default, so connecting the buzzer there is enough. The command music.pitch(262, 500) plays a 262 Hz tone (the note C) for half a second.
Lighting an LED with digital write
Instead of sound, you can light an outside LED. Connect the LED's long leg (positive) to pin 0 through a resistor, and its short leg to GND. Then write digital 1 to pin 0.
from microbit import *
while True:
if button_a.is_pressed():
pin0.write_digital(1) # LED on
else:
pin0.write_digital(0) # LED off
Mini practice
In this practice you plan the connection before you make it. The goal is to think about choosing the right pin and connecting the part in a safe order.
Imagine you have these: a micro:bit, a buzzer, a few crocodile clips, and an adult's help.
Task: Fill in the plan below and write down which pin you use at each step.
Connection plan (you fill it in):
1. Buzzer (+) ----> micro:bit pin ________
2. Buzzer (-) ----> micro:bit pin ________
3. Code: Which pin should the audio output be set to? ________
4. Check: Does the sound play when you press button A? (It should)
5. Check: Did you power the board off before removing the clips?
Check questions:
- Why did you connect the buzzer's positive end to a signal pin (0) and its negative end to GND?
- If you wanted to change the sound gradually, would you write digital or analog?
- If you added an external button to this project, which pin would you read it from?
There is no single correct layout. What matters is that the connection is safe, uses the right pins, and matches the code.
Common mistakes
Using the wrong pin
A common mistake is connecting the buzzer to the 3V or GND pin and expecting a signal. Sound and general signals come from the input/output pins such as 0, 1, and 2; 3V and GND are only for power.
Forgetting to connect GND
An outside part will not work with just a signal pin; the circuit must be completed with a GND (negative end) connection too. If there is no sound or light, check the GND cable first.
Confusing digital and analog
If you want to set brightness gradually but use write_digital, you only get fully on or fully off. For a gradual change you need write_analog. Pick the right command for what you want.
Connecting an LED without a resistor
Connecting an outside LED straight to a pin can draw too much current and harm the LED or the board. Always place a suitable resistor between the LED and the pin, and check it with an adult.
Safety note
- Set up external parts and battery connections with an adult's help; check together that each cable goes to the right pin.
- Work only with low voltage: power the micro:bit from USB or the recommended 2×AAA battery pack. Never use mains electricity or a wall socket.
- Choose the correct pin and voltage: 0/1/2 for signals, 3V and GND for power. Do not short the circuit by touching 3V directly to GND.
- It is a good habit to power the board off while plugging and unplugging cables.
- On wearable or bicycle projects, attach parts securely so connections do not come loose from rubbing. Never let a device distract you while cycling.
- If the board or battery gets hot or gives off a smell, tell an adult right away.
Lesson summary
- The pins along the bottom edge connect the micro:bit to outside parts; 0, 1, 2 are input/output, 3V is power, and GND is the negative end.
- Crocodile clips make an easy, solder-free connection to the large pins.
- A digital signal takes only 0 or 1; an analog signal takes gradual values from 0 to 1023.
- We can write a signal to pins (output) or read a signal from them (input).
- We can connect a buzzer to pin 0 and play sound with both MakeCode and MicroPython; for safety, do the build with an adult.
Check questions
- What are the 3V and GND pins on the micro:bit used for?
- Which pin do we traditionally connect a buzzer to in order to play sound?
- What is the main difference between a digital signal and an analog signal?
- If we want to take a signal in from an outside part, how do we use the pin: by writing or by reading?
- Why do we place a resistor when connecting an external LED to a pin?
Answers
- The 3V pin gives positive power (supply) to a part, and the GND pin is the negative (ground) end of the circuit. Together they provide the power a part needs to work.
- We traditionally connect it to pin 0; the micro:bit's
musicmodule and music blocks send sound out of this pin by default. - A digital signal takes only two values: 0 (off) or 1 (on). An analog signal can take many gradual values from 0 to 1023, which lets us set things like brightness or tone slowly.
- We use the pin by reading it; that is, we treat the pin as an input and take the incoming signal with
read_digitalorread_analog. Writing is for sending a signal out. - The resistor limits the current flowing through the LED. Without it, too much current could strain the LED or the pin; the resistor lowers that risk.
Source and verification note
For “Pins and External Components”, verification focuses on whether the relationship between What are the edge pins? and Digital and analog: writing and reading remains consistent across examples. MakeCode and MicroPython names can vary slightly by version. Test in the simulator first; when external components are connected, check the board’s pin and voltage limits separately.
Next lesson
micro:bit with Python: We move from MakeCode blocks to MicroPython and learn to write the same programs as text-based code.