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.

EasyFull instructions provided30 minutes1,004

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
Screenshot from 2018 03 29 20 39 17 8qp9kybeeq

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 • 16 followers
Azure and IoT

Comments

Add projectSign up / LoginAbout BBC micro:bit