A wired network with GPIO pins
We can use the GPIO pins of the Micro:bit to create very primitive networks that exchange data in binary format. We know that the HIGH signal (which corresponds to 1) and LOW signal (which corresponds to 0) represent binary data. We will use the built-in write_digital()
method to exchange 1s and 0s between devices. Let’s use two Micro:bit devices to create a simple circuit to exchange binary data:
Figure 13.1 – Micro:bits connected together
Let’s write a simple program that sends 1 over pin 0 if the A button is pressed and sends 0 otherwise. Similarly, we will read pin 1; if a device reads 1, then it will show a heart symbol and a smiley face otherwise. Here, pin 0 acts as a transmitter, and pin 1 acts as a receiver for both devices.
Upload this program to both devices and test it by pressing the A buttons on both devices:
from microbit import * try: while True: &...