BBC micro:bit
Connecting micro:bits Together

Introduction

Using some alligator cables, you can connect two micro:bits together in order to send and receive messages.

The Circuit

We need to make 2 connections. On each micro:bit, we need two pins to work for us.

NamePinRole
TXpin 0Transmit
RXpin 1Receive

We'll use these same pins on each micro:bit. You cross the cables so that the TX (transmit) pin on the left micro:bit attaches to the RX (receive) pin on the right hand one.

micro:bit circuit

The Program

Each micro:bit runs the same program. Press button A to turn the LEDs of the other micro:bit on.

micro:bit code

Challenges

  1. We can only measure two states here. If we want to detect the moment a button was pressed, you need to look out for a change from 0 to 1, low to high. To do this, make a variable and set it to 0. In the forever loop, check if the reading is 1 and the previous reading 0. Just before the end of the forever block, set the variable to equal the current reading. Use this technique to allow the remote micro:bits to do something only once for each button press.
  2. Work out a suitable set of images that need two micro:bits to make sense - 10x5 or 5x10 images. Use your RX and TX pins to control the action on both devices. You might find that this works better with a one-way approach to the communication.
  3. Work out a system for sending and receiving pulses of 1s of varying lengths. Use each button to trigger the sending of long and short pulses. Work out whether a long or short pulse has been received. The obvious thing to do is light up the other micro:bit's display Morse code style. You could also consider that, if you can read the difference between a long and short pulse being sent, you are sending a 1 or a 0. This is not the same as we had before. There we were essetially turning the power on and off. Now, you know that a digit has been sent. This allows you to send numbers in binary. Slightly easier, you could generate the pulses on one micro:bit and use them to turn each LED in the matrix on or off.
  4. Like Will has already done, try writing this in MicroPython. Will is smart. Be like Will.