Use the Serial Monitor
Micro:bit’s MakeCode Editor doesn’t have its own serial terminal, but we can use an online one that displays messages from the micro:bit. You can also type messages into the serial terminal to send them to the micro:bit.
A nice thing about the serial terminals is that there’s no need to wait for messages to scroll across the micro:bit module’s LED matrix display. You’ll be able to see the whole massage, all at once.
Different MakeCode blocks display messages in the serial terminal. Instead of show icon and show string for the LED matrix, you’ll be using serial write blocks to display messages and input statements to collect the text of messages you type.
This activity will use an example project that makes the micro:bit communicate with the serial terminal. The micro:bit will prompt you to type some text, and then repeat back what you typed.
- Enter these blocks into the micro:bit Makcode Editor.
- Click Download to make the micro:bit run it.
- Verify that the micro:bit module’s LED matrix display does not display anything.
- Open another browser and navigate to Google Chrome Labs Serial Terminal. (Click Connect and choose your micro:bit then click Connect again)
- Make sure to check the box that says Local echo.
- Check for the ‘Type a message:’ prompt. If it doesn’t appear, try clicking the Download button again. You might need to try it more than once before it takes.
- If the ‘Type a message’ prompt did not appear and clicking the Download button a couple of times doesn’t fix it, try this:
- Press the Disconnect button and reconnect the micro:bit.
- Then, click the Download button again, and it should start working.
- If the ‘Type a message’ prompt did not appear and clicking the Download button a couple of times doesn’t fix it, try this:
- Click to the right of the ‘Type a message:’ prompt, type a message, and press the Enter key.
- Make sure the serial terminal responds with ‘You typed:’ and then a repeat of the message you typed.
- If some of the letters are randomly missing don’t worry about it, it’s the terminals fault not the codes.
Try this: Display What You Type in LED Matrix too
- Add show string (text) immediately below the serial write line (join (‘You typed:’, text)) block.
- Click Download.
- Type a message into the serial terminal.
- Verify that the message you typed is displayed on both the serial terminal AND on the micro:bit module’s LED matrix.