MakeCode has a beta set of blocks for serial communications. You will need to use the web address https://makecode.adafruit.com/beta. Click New Project. Then Click the ADVANCED block group then the EXTENSIONS button under that. One of the experimental extensions is Serial. Click that and you should see back on the main block editing page a new block group SERIAL.
These are the blocks you can use to connect to external serial peripherals and serial to USB devices.
Here is a simple program to write the light level and temperature read by the Circuit Playground Express to a serial interface. The serial redirect
block sets up the communication pads and the baud rate. The program below uses the pads marked TX and RX for transmit and receive. If you use other pads, they will work but you are not using the hardware serial on the board but a software serial code function which is fine for the low transmission rates allowed by the block (no greater than 115,200 baud).
The hardware setup is shown on the page USB Converter Connections.
If you open up a terminal program and set it for your communications port at 115,200 baud, you'll get the output similar to that below:
If you get garbled text, you don't have the right baud rate, close the terminal and rerun the terminal program with the correct baud rate (for the code shown, that is 115,200).
If you get nothing, check the following:
- Is the Power On green LED on Circuit Playground Express? If not, add the correct power supply.
- Did you load the MakeCode onto the Circuit Playground Express?
- Are your connections such that the Circuit Playground Express TX pad connects to the converter RX (white wire) and that the RX pad connects to the TX (green wire) on the converter? They must be crossed for serial connections between devices).
- Ensure your terminal emulator is set for 115200 baud. For PuTTY, this is in the opening screen, with the COM port number the one from the Control Panel -> Devices and Printers for the Silicon Labs CP210x USB to UART Bridge device.
Text editor powered by tinymce.