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.

EasyProtip1 hour895
Micro:bit Basics for Teachers Part 2: Javascript Blocks

Things used in this project

Hardware components

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

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

23 projects • 208 followers
I live on a boat. Microcontroller enthusiast. Web & App developer.

Comments

Add projectSign up / LoginAbout BBC micro:bit