Monica Houston
Published © CC BY-SA

Micro:bit Basics for Teachers Part 2: Javascript Blocks

Teachers: get over your fear of code by "coding" with fun micro:bit javascript blocks.

BeginnerProtip1 hour2,024
Micro:bit Basics for Teachers Part 2: Javascript Blocks

Things used in this project

Story

Read more

Code

Javascript code

JavaScript
Here's the code from behind the blocks
let temp = 0
// “If the temperature is too cold or too hot, show an
// led alert”
basic.forever(() => {
    temp = input.temperature()
    basic.showNumber(temp)
    if (temp > 27) {
        basic.showIcon(IconNames.Angry)
    } else if (temp < 26) {
        basic.showIcon(IconNames.Surprised)
    } else {
        basic.showIcon(IconNames.Happy)
    }
})

Credits

Monica Houston

Monica Houston

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

Comments