A simple radio communication experiment using two Micro:bit boards, which can transmit and receive command to/from each other. Watch the video below to see it in action, then follow the instructions to build your own!
What You Need πTo build this project, you will need the following items:
- 2X Micro:bit boards
- 2X micro USB cables
- A PC/laptop with any OS
- First, open Microsoft Makecode for Micro:bit site (https://makecode.microbit.org/) to create commands for Micro:bit. You can write the code using Javascript or simply choose Blocks menu.
- If you choose Javascript, write the lines below:
input.onButtonPressed(Button.A, () => {
radio.sendString("A A A")
})
input.onButtonPressed(Button.B, () => {
radio.sendString("B B B")
})
radio.onDataPacketReceived(
({ receivedString }) => {
basic.showString(receivedString)
})
for (let i = 0; i < 5; i++) {
basic.showIcon(IconNames.SmallDiamond)
basic.pause(100)
basic.showIcon(IconNames.Diamond)
basic.pause(100)
basic.showIcon(IconNames.Target)
basic.pause(100)
}
basic.pause(500)
radio.setGroup(43)
basic.showIcon(IconNames.Heart)
basic.forever(() => {})
- If using Blocks, arrange the code like the following picture:
Blocks
- After that, click Download button to get a .hex file for your Micro:bit board. Simply connect your Micro:bit to your PC/laptop, then paste the .hex file into it.
- Done! You're ready to go! π
Comments