Anish Ansari
Published © LGPL

How to Create Temperature Gauge Using Micro:bit

By the end of this tutorial, you will be able to make your own simple temperature gauge using micro:bit.

BeginnerFull instructions provided30 minutes9,963

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
AA Batteries
AA Batteries
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
RobotGeek 180 Degree Robot Servo
RobotGeek 180 Degree Robot Servo
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Story

Read more

Schematics

Connection

Connection for the servo

Code

Code for temperature gauge

JavaScript
This is the code for temperature gauge
let temperature = 0
basic.forever(() => {
    temperature = input.temperature()
    if (temperature < 20) {
        temperature = 20
    } else if (temperature > 35) {
        temperature = 35
    }
    pins.servoWritePin(AnalogPin.P0, pins.map(
    temperature,
    20,
    35,
    0,
    180
    ))
})

Credits

Anish Ansari

Anish Ansari

11 projects • 41 followers
Azure and IoT

Comments

Add projectSign up / LoginAbout BBC micro:bit