Skip to content

Latest commit

 

History

History
68 lines (43 loc) · 2.06 KB

christmas-bauble.md

File metadata and controls

68 lines (43 loc) · 2.06 KB
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 %}

Code Explained

{: .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.

Reading the API

{: .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.

Going Further

{: .ui .dividing .header}

This only scrolls the message once. Read the API to make it repeat.

{% include box.html content="strings-integers" %}