1. Hello World

Micro:Bit + MicroPython Basics


###################################
#
#  Basics Of Micro:Bit micropython
#  coding.  1: Hello World
#  import and text scrolling
#
###################################

# text after a # is a comment
# the M:B ignores comments
# it's just a way to leave notes
# for yourself in a programming

# to work on the M:B, you need to import
# the microbit module
# (the * means get everything)
from microbit import *

# to scroll a message on the M:B
# you use the function display.scroll()
display.scroll("Hello World!")

# sleep tells the M:B to pause
sleep(2000)     # 2000 = 2 seconds

# this will only scroll the message once
# there are two ways to make it scroll
# repeatedly and one of them is...
display.scroll("Hello Universe", loop=True)
          

Next Page >>