Getting Started With JavaScript Blocks: Flashing HeartWorksheet
Challenge7
You are going to design, test and build a program that will send a message between two micro:bits. By pressing A or B a different image of a heart will be sent to the second micro:bit
Step 1
Head to the micro:bit website and go to the Let’s Code tab. JavaScript Block Editor.
Open the JavaScript BlocksEditor, you should see something like this.
Remove all the blocks by either dragging each block back to the library or selecting the block and pressing the delete key.
Self-Assessment
I can load up the software on the Micro: Bit website.
I can clear the workspace ready for building a new program.
Step 2
You will be using the radio function. You need two micro:bits both working together. To make sure your micro:bits communicate correctly you need to choose a “Radio Set Group” number that is different to everyone else in the room.
Radio Group Number / Partner nameStep 3
Explain in your own words what needs to happen to get to micro:bits to communicate. Think about how you communicate.
micro:bit 1 / How do they talk to each other? / micro:bit 2Self-Assessment
I can consider what is needed to create communication
Step 4
Call one of your micro:bits the transmitter and the other micro:bit the receiver.You will write a different program for each micro:bit.
Step 5
Think about the Transmitter program. This needs to send messages to the Receiver micro:bit. If the A button is pressed the micro:bit send a radio number of 1. If the B button is pressed the micro:bit sends a radio number of 2.Create a flowchart of the program.
Transmitter micro:bit / Transmitter FlowchartStep 6
Think about the Receiver program. If the micro:bit receives a 1 the micro:bit displays the full heart pattern. If the micro:bit receives a 2 the micro:bit displays the outline of the heart pattern.
Receiver micro:bit / Receiver FlowchartStep 7
Screen print of Transmitter programScreen print of Receiver program
Step 8
Once tested, place both the transmitter and receiver in a single program to allow 2-way communication.
Self-Assessment
I can …
Work together on 2 micro:bits
Plan a program using a flowchart
Send a message wirelessly between 2 micro:bits
Challenges
Well done for completing the Flashing Heartproject. Now you can see it working, can you try to modify your code so it does some or all of the challenges below.
- Send a written message to the second micro bit.
- Allow the user to choose a picture and send it to the second
- Allow a third micro:bit to send and receive data
1
micro:bit Educational Foundation 2016