Hackster is hosting Impact Spotlights: Smart Home. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Smart Home. Stream on Thursday!
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,054
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
79 projects • 461 followers
I don't live on a boat anymore.
Contact

Comments

Please log in or sign up to comment.