title | layout | meta-description | simple-description | share | comments | author | video | strapline | aboutbox | cats | date | date-updated |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Scrolling Bauble |
text-width-sidebar |
Python program to create a scrolling bauble on the BBC Microbit. |
Christmas Bauble |
true |
true |
jez |
true |
Scroll text on the microbit display |
Make a simple Christmas bauble to scroll a festive message across the display. |
easy |
2016-12-23 10:20:00 UTC |
2016-12-23 10:20:00 UTC |
{% highlight python %} {% include_relative code/christmas-bauble.py %} {% endhighlight %}
{: .ui .dividing .header}
from microbit import *
This imports the microbit module into the program. *
imports everything in the module.
Since we only use the display
module, we could use from microbit import display
.
display.scroll("ho ho ho")
Scrolls the text across the micro:bit's display. Everything inside the "
is shown in the display. Characters within "
are strings.
{: .ui .dividing .header}
The microbit API for the display module describes a delay
parameter for the scroll
method.
display.scroll("ho ho ho", delay=500)
updates the display every 500 milliseconds (or half a second). It slows down the speed of the scrolling text.
The API documentation has information that microbit module. Try reading it when you're coding for ideas. The Python community are also famously helpful - search online for mailing lists and message boards that may contain the help you need. If in doubt, ask for help.
{: .ui .dividing .header}
This only scrolls the message once. Read the API to make it repeat.
{% include box.html content="strings-integers" %}