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
- Define a variable called
boatand store the boat image in it.
from microbit import *
boat = Image("05050:"
"05050:"
"05050:"
"99999:"
"09990")
display.show(boat)
- Create two new variables:
my_squareandmy_arrow.
Use theImage(...)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)
- Put all 4 images into a list called
my_images.
my_images = [boat, my_square, my_arrow, my_star]
- 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)
- Make it run continuously.
Hint: wrap it in awhile 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
PX_lastname_boatSquareArrowStar.png— Screenshot inside Python editor showing your code.PX_lastname_boatSquareArrowStar.py— Your Python source file.PX_lastname_boatSquareArrowStar.txt— Plain-text copy of your code.PX_lastname_boatSquareArrowStar.hex— Hex file to run on the physical micro:bit.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.