micro:bit Project - Two Person Telegraph
This project is not as complicated as it looks. The purpose of this project is to connect two micro:bits together using crocodile clips and to transmit messages between them.
What You'll Need:
- 2 x BBC micro:bit devices
- 1 x Micro USB lead
- 2 x AAA Batteries & Battery Holder
- 4 x Crocodile Clips
- 1 x Computer (for writing and transferring your code)
- Project Walkthrough
Select two 'if/then/else' blocks from the Logic commands menu and place them both inside a 'forever' loop.
The first 'if/then/else' block will be used to send a message from your BBC micro:bit to the device it's connected to.
Drag in a 'button [A] is pressed' block from the Input commands menu and attach it next to 'if'.
For 'then', go to the Pins menu (under Advanced) and attach a 'digital write pin [P0] to ' tile. Set the pin to [P1] and change the  to a .
Add a second 'digital write...' tile next to 'else', also changing the pin to [P1] and ensuring that this time the value is set .
When you press button A now, your device will send a current through pin P1. Otherwise, there will be no current through this pin. When your device is connected to your partner's BBC micro:bit via the crocodile clips, this is how they will communicate.
Next you need to tell your device what to do when it receives a message from your partner's BBC micro:bit (the message arrives in the form of the aforementioned current). For the purposes of this project, we're just going to create a simple telegraph - meaning that when your BBC micro:bit receives the message from the connected device, it will flash up a light on the LED.
In the second 'if/then/else' block, attach a ' = ' block from the Logic commands. This will be our condition for this if statement.
Within this logic block replace the first  with 'digital read pin [P0] to ' block and set the dropdown to [P2].
Now change the value in the right dialog box to . The 'if' block is now listening for a message on P2 by checking it for an active current.
Look at the next code sample (below). The 'plot' and 'unplot' blocks that have been added are used to turn individual LEDs on and off. When your device receives a current through pin P2, it will flash the LED at co-ordinates X2, Y2.
Make sure this code is compiled and downloaded to both BBC micro:bits.
To connect the two BBC micro:bits, take your first pair of crocodile clips and attach each end to the GND pin on both devices. Then attach your second pair of crocodile clips to the 3V pin on each device.
Take your third pair of crocodile clips and attach one end to Pin 1 on your first BBC micro:bit. Connect the other end to Pin 2 on the second device.
Do the reverse with your fourth and final pair of crocodile clips. attaching one end to Pin 2 on the first device, and the other to Pin 1 on the second.
Your devices are now ready to communicate! Make sure your code is downloaded to both devices, and hit button A to start communicating!
Now that you've established a connection, can you think of a way of actually sending meaningful messages? The micro:bit has two buttons - maybe there's a way of sending a more complicated message using those?