Microbit Counter

from microbit import *

count = 0

while True:
    if button_a.was_pressed():
        count += 1
    elif button_b.was_pressed():
        display.scroll(str(count), delay=100)
    elif button_a.is_pressed() and button_b.is_pressed():
        count = 0
        display.scroll("Reset", delay=100) 
Share On
Facebook Twitter Google Plus

Published: December 23, 2016 Updated: December 23, 2016

Microbit Counter

A super-simple program to count how many times a button was pressed.

Jez Dean