Anish Ansari
Published © LGPL

Communication of Micro:Bit Using Radio Signal

By the end of this article, you will know how to make two micro:bits communicate with each other.

EasyFull instructions provided30 minutes1,497

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×2
AA Batteries
AA Batteries
×4
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Story

Read more

Code

Code for Radio Communications

JavaScript
radio.onDataPacketReceived(({ receivedNumber }) => {  
    if (receivedNumber == 1) {  
        radio.sendNumber(2)  
        basic.showIcon(IconNames.Heart)  
        music.beginMelody(music.builtInMelody(Melodies.PowerUp), MelodyOptions.Once)  
    }  
    if (receivedNumber == 2) {  
        music.beginMelody(music.builtInMelody(Melodies.PowerUp), MelodyOptions.Once)  
    }  
})  
basic.forever(() => {  
    if (input.buttonIsPressed(Button.A)) {  
        radio.sendNumber(1)  
        basic.pause(200)  
    }  
})   

Credits

Anish Ansari

Anish Ansari

14 projects • 23 followers
Azure and IoT

Comments

Add projectSign up / LoginAbout BBC micro:bit