Alex Glow
Published © GPL3+

Pomodoro Sand Timer on Micro:bit

Break your big, ugly tasks into cute little chunks using the Pomodoro Technique! This simple project uses MicroPython to make it happen.

BeginnerProtip30 minutes1,150
Pomodoro Sand Timer on Micro:bit

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Mu Editor

Story

Read more

Code

Pomodoro code

MicroPython
I didn't write this in an "intelligent" (non-blocking) way, so if you want to restart the timer, you'll need to hit the Reset button before selecting button A or B again. (A potential future upgrade.)
from microbit import *

# Reference: https://microbit-challenges.readthedocs.io/en/latest/tutorials/control.html#for-loops

while True:
    if button_b.is_pressed():   # 1 minute = 60 seconds
        secno = 60
        display.show(Image.HEART)
        sleep(1000)
        display.clear()
        for y in range(0,5):    # count-up timer
            for x in range(0,5):
                sleep(1000*secno)
                display.set_pixel(x, 4-y, 6)
        for b in range(0,6):    # break timer
            display.clear()
            brk = str(5-b)
            display.show(brk)
            sleep(1000*secno)
            
    if button_a.is_pressed():   # 1 minute = 2 seconds, for testing
        secno = 2
        display.show(Image.HEART)
        sleep(1000)
        display.clear()
        for y in range(0,5):
            for x in range(0,5):
                sleep(1000*secno)
                display.set_pixel(x, 4-y, 6)
        for b in range(0,6):
            display.clear()
            brk = str(5-b)
            display.show(brk)
            sleep(1000*secno)

Credits

Alex Glow

Alex Glow

145 projects • 1570 followers
The Hackster team's resident Hardware Nerd. I love robots, music, EEG, wearables, and languages. FIRST Robotics kid.

Comments