Cybersecurity course logo
Cybersecurity · micro:bit · Variables & Images

PX_lastname_boatSquareArrowStar

Instructions

Lesson 3

Launch the micro:bit Python editor

Use the new version of the micro:bit hardware.

Steps

  1. Define a variable called boat and store the boat image in it.
from microbit import *

boat = Image("05050:"
             "05050:"
             "05050:"
             "99999:"
             "09990")

display.show(boat)
  1. Create two new variables: my_square and my_arrow.
    Use the Image(...) command to build your own images.
my_square = Image("99999:"
                  "90009:"
                  "90009:"
                  "90009:"
                  "99999")

my_arrow = Image("00900:"
                 "09990:"
                 "90909:"
                 "00900:"
                 "00900")
				 
my_star = Image(??????????????????????) (This needs to be fixed)
  1. Put all 4 images into a list called my_images.
my_images = [boat, my_square, my_arrow, my_star]
  1. Display all four images from the list, one after another.
    Use a delay so you can actually see them.
display.show(my_images, delay=200)
  1. Make it run continuously.
    Hint: wrap it in a while True: loop and include a pause.
while True:
    display.show(my_images, delay=200)

Guides / References:
Click here for guidance.
Click here for guidance.

Hint: To clear the display:

display.clear()
# Sets the brightness of all LEDs to 0 (off)

The name of the file will be:
PX_lastname_boatSquareArrowStar

Files to save on Google Drive under your class and submit to Google Classroom

  1. PX_lastname_boatSquareArrowStar.png — Screenshot inside Python editor showing your code.
  2. PX_lastname_boatSquareArrowStar.py — Your Python source file.
  3. PX_lastname_boatSquareArrowStar.txt — Plain-text copy of your code.
  4. PX_lastname_boatSquareArrowStar.hex — Hex file to run on the physical micro:bit.
  5. PX_lastname_boatSquareArrowStar.mp4 — Short demo video of the program running on the board.

Submission requirements

  • Show the real micro:bit hardware running your animation to Mr. Cusack.
  • Get the secret code word after you demo.
  • Include that exact code word in your Google Classroom submission comments.