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.

EasyProtip30 minutes216
Micro:bit Basics for Teachers Part 3: MicroPython

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1

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

20 projects • 190 followers
I live on a boat. Microcontroller enthusiast. Web & App developer.
Contact

Comments

Add projectSign up / LoginAbout BBC micro:bit