Coding it to a counter.

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
livesf
Posts: 1
Joined: Tue Aug 15, 2017 6:45 pm

Coding it to a counter.

Post by livesf » Tue Aug 15, 2017 6:50 pm

Hello,
I want to be able to press a button and it adds 1, and it displays it on the micro:bit. How would I be able to do this?
Thanks.


rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

Re: Coding it to a counter.

Post by rhubarbdog » Wed Nov 15, 2017 1:16 am

Code: Select all

from microbit import *

total=0
while True:
    if button_a.is_pressed():
        total+=1
        display.scroll(str(total),wait=False)

Post Reply