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.

BeginnerFull instructions provided30 minutes10,459

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

11 projects • 41 followers
Azure and IoT

Comments

Add projectSign up / LoginAbout BBC micro:bit