Micro:bit Stopwatch

by jorreb in Circuits > Microcontrollers

562 Views, 0 Favorites, 0 Comments

Micro:bit Stopwatch

F54HOFEKUV8XFGN.jpeg

I always wanted to know how a timer worked and I think it is good to know how a timer works

A timer is handy to have wen you want to know how long something takes to do or if you want to time something and that is why I am going to make a timer 

Supplies

1x BBC micro:bit

1x Computer to make and upload program/code

1x USB cable

Write Program

microbit.JPG
code.JPG

this program is made in Microsoft https://makecode.microbit.org/ and I will guid you step by step

wen you are in Microsoft MakeCode klik on new project and then follow these steps

take (on button A pressed)  from input and place it .

make a variable named start in variables then take (set start to) and place it in (on button A pressed).

then go to input more and take (running time ms) and place it in (set start to).

next take a (on butten A pressed) and change the letter to B and place it separately from the first one.

make a new variable named elapsed and then take (set elapsed to) and place it in (on button B pressed).

go to math and take (0-0) and place it in (set elapsed to).

then go input more and take (running time ms) and place it in the left side of (0-0).

go to variables and take (start) and place it in the right side of (0-0).

then go to basic and take (show number 0) and place it in (on butten B pressed) onder (set elapsed to)

go to math and take (0/0) and place it in (show number 0)

then place the varieble named (elapsed) in the left side of (0/0)

and in the right side of (0/0) you typ 1000


that is the code


Test Program

microbit.JPG

Use the emulator to test the program. if it doesn't work you can change the code

Download and Upload Program

Simply download the program from the bebsite and then upload it into the micro:bit

Use It

have fune with your new stopwatch and try to time your 100m sprint