The challenge we have set for you is to connect some electrical components to a micro:bit for computer control.
A simple electrical circuit to light up an LED will need a source of electrical power, an LED and some wires.
LED wired to a 1.5 volt electrical cell
Computers are used to control billions of devices.
A good example is the traffic light
You are going to learn how to use a micro:bit computer to control a light.
The light you control
will be a red LED
The micro:bit's brass edge strip has five holes called pins for connecting external electrical components.
They are labelled, 0, 1, 2, 3V and GND .
Wires are held in the pins using plastic pegs called micro:pegs or crocodile clip to crocodile clip leads.
The images below show how to connect a wire to a pin using a micro:peg.
The image below shows how to connect a wire to a pin using a crocodile clip to crocodile clip lead.
Note that the crocodile clip is attached at rightangles to the micro:bit with one jaw pushed through the hole.
Connect the red LED to the micro:bit as follows:
Connect the red wire of the LED to pin 0.
Connect the black wire of the LED to the GND pin.
Copy the picture below.
Push the micro:pegs in firmly so they do not fall out.
In the MakeCode editor, find the red blocks in the Advanced library.
Then create the code below.
Test your code using the simulator.
Click on button A.
Did a 1 appear by Pin 0 to indicate that it is turned on?
Did Pin 0 turn off after a second?
Did Pin 0 turn ob again after a second?
Did this sequence happen four times?
If it did, then your code is free of bugs and is ready to download to your micro:bit.
You will have observed a pattern in the working of the LED.
Can you recognise this pattern in the code you created to control the LED?
Work out what do the following blocks do in the control program?
on button A pressed
repeat 4 times do
digital write P0 to 1
pause (ms) 1000
digital write P0 to 0
Download the code to the micro:bit and test it.
If the red LED starts to flash.
Congratulations!
The physical computing worksheet