Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
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,042
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

78 projects • 454 followers
I don't live on a boat anymore.

Comments