Josiah Densmore
Published © GPL3+

Micro:bit Screen Showing Time and Temperature

Display screen Showing time and temperature with your micro:bit.

IntermediateFull instructions provided1 hour3,377
Micro:bit Screen Showing Time and Temperature

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
BBC Micro:bit LCD Module 1.8" Colorful Display 160x128 ST7735S Driver 65K colors
×1
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
×1

Software apps and online services

pxt.microbit.org
micro:bit pxt.microbit.org

Story

Read more

Schematics

Photos

Photos

Blocks

Code

Code

JavaScript
let Refresh_Time = 0
let min = 0
let Refresh_Temp = 0
let hour = 0
input.onButtonPressed(Button.A, () => {
    hour += 1
})
input.onButtonPressed(Button.B, () => {
    min += 1
})
Refresh_Temp = input.temperature() * 9 / 5 + 32
Refresh_Time = min
LCD1IN8.LCD_Init()
LCD1IN8.LCD_SetBL(330)
LCD1IN8.LCD_Display()
LCD1IN8.LCD_Clear()
basic.forever(() => {
    LCD1IN8.DisNumber(
    32,
    50,
    input.temperature() * 9 / 5 + 32,
    LCD1IN8.Get_Color(LCD_COLOR.RED)
    )
    LCD1IN8.DisString(
    50,
    50,
    "F",
    LCD1IN8.Get_Color(LCD_COLOR.RED)
    )
    LCD1IN8.DisNumber(
    32,
    60,
    input.temperature(),
    LCD1IN8.Get_Color(LCD_COLOR.BLUE)
    )
    LCD1IN8.DisString(
    50,
    60,
    "C",
    LCD1IN8.Get_Color(LCD_COLOR.BLUE)
    )
    LCD1IN8.LCD_Display()
})
basic.forever(() => {
    LCD1IN8.DisNumber(
    53,
    32,
    min,
    LCD1IN8.Get_Color(LCD_COLOR.BLACK)
    )
    LCD1IN8.DisString(
    42,
    32,
    ":",
    LCD1IN8.Get_Color(LCD_COLOR.BLACK)
    )
    LCD1IN8.DisNumber(
    26,
    32,
    hour,
    LCD1IN8.Get_Color(LCD_COLOR.BLACK)
    )
})
basic.forever(() => {
    if ((hour == 12 && min) == 60) {
        hour = 1
        min = 0
    }
    if (min == 60) {
        min = 0
        hour += 1
    }
})
basic.forever(() => {
    if (Refresh_Time != min) {
        Refresh_Time = min
        LCD1IN8.LCD_Clear()
    }
    if (Refresh_Temp != input.temperature() * 9 / 5 + 32) {
        Refresh_Temp = input.temperature() * 9 / 5 + 32
        LCD1IN8.LCD_Clear()
    }
})
basic.forever(() => {
    basic.pause(60000)
    min += 1
})

Credits

Josiah Densmore

Josiah Densmore

4 projects • 5 followers

Comments