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
  • Writing micro:bit programs

Writing micro:bit programs

Scrolling Text

Scrolling text across the display is a very useful way to get information from your micro:bit program.  When you have your micro:bit on your cyber:bot robot, this is a good way to display values from the robot’s sensors.

To scroll text across the display, use the aptly named display.scroll method.  The text you want to display goes inside quotation marks ” “, and that goes inside the method’s parentheses ( ).

Example script: hello

  • Connect your micro:bit module to your computer with its USB cable.
  • In a Google Chrome or Microsoft Edge browser, go to python.microbit.org to open the micro:bit Python Editor.
  • Enter, name, and save the hello script.
    (See Save & Edit Scripts.)  
  • Click Send to micro:bit.
    (See Flash Scripts with Python Editor.)
#hello

from microbit import *

display.scroll("Hello")

You should see the word Hello scroll across the display one character at a time.

  • Did you miss it? Press the reset button on the underside of the micro:bit module to see the Hello message repeat.

How the hello script works

The first line, #hello is a comment. It is just there for you to read the script’s name, but is ignored by the micro:bit. We will look at comments again later!

The second line, from microbit import *,  fetches the code that knows how to run the display methods.  Every complete example script in these tutorials will have at least one import * statement at the top. 

The third line makes the text appear on the display.  The “Hello” text in quotation marks is a parameter of the display.scroll method, and so goes inside its parentheses.

Try This: Speed Control

The text you want to display isn’t the only parameter you can use with display.scroll.  You can control the speed at which the text scrolls across the display by adding a an additional parameter to the display.scroll method called delay. The larger the value for delay, the slower the text will scroll. 

  • Set the script name to hello_goodbye.
  • In the first display.scroll statement, add delay = 500 as shown below. Don’t forget the comma between the parameters!
  • On a new line, add a second display.scroll statement that says Goodbye, with a delay of 500.
  • Save the modified script.
  • Click the Send to micro:bit button.
#hello_goodbye

from microbit import *

display.scroll("Hello", delay = 500)
display.scroll("Goodbye", delay = 150)

You should see the word Hello scroll across the display slowly, then the word Goodbye scroll across the screen quickly.

Be cautious when copying and pasting code with quotation marks! Some types of documents use smart-quote characters ” and ” that will result in a syntax error if you try to use them in a script.  If you are receiving a syntax error after copying and pasting code with quotation marks, try erasing and retyping the quotation marks directly in your programming environment, then re-flash the program.

Your Turn: Your Name

  • Write a script to scroll your first name across the display.
  • Modify your script to scroll your first name across the display quickly, then scroll your last name across the display slowly.

 


Printer-friendly version
LED Matrix
Prev
Premade Images
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2025 Parallax Learn • Built with GeneratePress