To run a script and see its print statements, simply click the terminal pane and then press CTRL + D. In Mu, there’s a REPL button that opens a terminal pane and puts the micro:bit into REPL mode. To exit a running script and go straight to the REPL prompt, you can also click the “ Send CTRL-C for REPL.” Print Text - Mu To reset the micro:bit, you can also click the black Terminal pane and press CTRL+D ( CMD+D in Mac). Whenever “ CTRL-D to reset” is clicked, the micro:bit will restart the script and display these lines again.
If the script ends by running out of statements, the terminal then displays technical information about the micro:bit, followed by a prompt to type help() for more info, and ends with the REPL prompt. In this case, it’s the Hello Terminal! message. After that, the micro:bit runs the script and whenever it executes a print statement, the result appears in the terminal. That’s letting you know that the terminal is doing the equivalent of pressing and releasing the micro:bit module’s Reset button, (which is next to its USB connector). Click the Close Serial button to get back to the script editor pane.Īfter clicking “ Send CTRL-D to reset”, the first message the terminal displays is soft reboot.Want to see it again? Click the Send CTRL-D to reset button.Verify that the Hello Terminal! message is displayed.Click the Open Serial button to open the terminal.Click Flash to load the script into the micro:bit.
(No more switching to a file browser and dragging files into the micro:bit drive!) With this connection, you can also flash scripts into the micro:bit by simply clicking the online editor’s Flash button. Now that the online editor is connected, you can run a script that prints a message and open the terminal to see that message. If it does, select your micro:bit from the list, then click the Connect button in the dialog. If you physically disconnected the USB cable, when you reconnect, a “python-editor… wants to connect” dialog might appear.If the label says Connect, click the button to connect.Check the Connect/ Disconnect button and make sure the label says Disconnect.Use your Chrome browser to navigate to.Connect your micro:bit module to your computer with a USB cable.If it displays “Connect”, it means the micro:bit is not connected and you need to connect it. If the second button from the left displays “Disconnect”, it means that the micro:bit is connected. The Online Editor has to be connected to the micro:bit before it can display text messages.
In this activity, you will print messages, values, and combinations of both in the terminal.
And, since you flash the script to the micro:bit, your code travels with your device. This can be helpful for displaying longer messages, and also for displaying what’s happening to values at certain points in your script. MicroPython scripts can also use print to display messages and values as the scripts run. As you’ve now seen, print function calls can be entered at the REPL prompt to display messages and values.