Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Computer – micro:bit Talk

Computer – micro:bit Talk

Projects that Print to Terminal

Recall from Using the Serial Monitor that you can flash a project to the micro:bit that prints a message, and open the Serial monitor to see that message. Makecode projects can also use serial write to display messages and values as the projects run. This can be helpful for displaying longer messages, and also for displaying what’s happening to values at certain points in your project. And, since you flash the project to the micro:bit, your code travels with your device.

In this activity, you will print messages, values, and combinations of both in the terminal.

Example project: print_to_terminal

  • Connect your micro:bit module to your computer with its USB cable.
  • In a browser, go to makecode.microbit.org to open the micro:bit Makecode Editor.
  • Enter and name it print_to_terminal.
    (See Save & Edit Projects.) 
  • Click Download.
    (See Flash Projects with MakeCode Editor.)

  • Navigate to a new browser and open Google Chromelabs Serial Terminal
    (See Use the Serial Monitor.)
  • Connect to your micro:bit using the connect button.
  • Verify that the Hello Terminal! message is displayed.

  • Want to see it again or nothing showed up?? Hit the reset button on the back of the micro:bit.

Pressing and releasing the micro:bit module’s Reset button, (which is next to its USB connector) restarts the project that’s currently flashed. After that, the micro:bit runs the project again and whenever it executes a serial write block, the result appears in the terminal. In this case, it’s the Hello Terminal! message. 

Try This: Print Something Different

What if you want to display a different message in the online editor? Try modifying the text inside the serial write block.

  • Change project’s name from print_to_terminal to print_to_terminal_try_this.
  • Replace the Hello Terminal! with your own new message.
  • Click the Download button.
  • Check the results in the serial monitor.

Did You Know?

The micro:bit’s serial write block is completely different from the show blocks and its methods. One of those outputs is not as fast as the other. The show methods are for the 5×5 LED grid, and each block has to display each character long enough for a human to read it. In contrast, the micro:bit serial write block can send characters very rapidly, with each character taking only about 1/10,000th of a second to transmit.

Example project: display Integer Values

You might have noticed that serial write can display values stored by variables, along with strings of characters. That same functionality is also available when you add serial write blocks to projects.

  • Enter and name the project print_value_to_terminal. 
  • Click the Download button.

  • Check the results in the serial monitor.
  • Verify that the terminal displays Hello Terminal followed by value = 10 on the next line.
  • If there are random missing letters ignore them, it’s not your program’s fault it’s the terminals.

Print Values to Terminal in a Loop

Let’s try a countdown timer in the terminal using a while loop. The while block repeatedly executes blocks that are indented immediately below it. The loop repeats “while” its condition is true. In this program, the while loop repeats while the value variable is greater than or equal to 0.

Example project: print_looped_terminal_values

  • Enter and name the project print_looped_terminal_values. 
  • Click the Download button.

  • Navigate to the serial monitor, if it’s not open go to Google Chromelabs Serial Terminal.
  • Click Download.
  • Verify that the terminal displays value = 5, value = 4, …value = 1, Blastoff!


Printer-friendly version

Leave a Comment Cancel reply

Meet the Terminal
Prev
Input Messages
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress