Monica Houston
Published © CC BY-SA

Micro:bit Basics for Teachers Part 3: MicroPython

Teachers: learn the basics for teaching your students to code with the micro:bit using MicroPython.

BeginnerProtip30 minutes1,486
Micro:bit Basics for Teachers Part 3: MicroPython

Things used in this project

Story

Read more

Code

Full Temperature Sensor Code

MicroPython
from microbit import *
snowflake1 = Image("05030:"
                 "90200:"
                 "01006:"
                 "30070:"
                 "40508")
snowflake2 = Image("30900:"
                 "05030:"
                 "90200:"
                 "01006:"
                 "30070")
snowflake3 = Image("40508:"
                 "30900:"
                 "05030:"
                 "90200:"
                 "01006:")
snowflake4 = Image("30070:"
                 "40508"
                 "01020:"
                 "00600:"
                 "05090")
snowflake5 = Image("01006:"
                 "30070:"
                 "40508"
                 "01020:"
                 "00600")
snowflake6 = Image("90200:"
                 "01006:"
                 "30070:"
                 "40508"
                 "01020")
                 
all_snowflakes = [snowflake1, snowflake2, snowflake3, snowflake4, snowflake5, snowflake6] 

while True:
    temp = temperature()
    display.scroll(str(temp))
    if temp >= 29:
        display.show(Image.ANGRY)
    elif temp < 28:
        display.show(all_snowflakes, loop=True, clear=False)
    else:
        display.show(Image.HAPPY)
    sleep(500)

Credits

Monica Houston

Monica Houston

75 projects • 446 followers
I don't live on a boat anymore.

Comments