Course Content
About BBC microbit
Micro:bit board is designed by BBC which aims to help children at or above 7 grade to learn programming better. Micro:bit board has abundant board resources, including a 5*5 LED metric dot array, 2 programmable buttons, Compass, USB ports, Bluetooth module etc.. It is only pocket size but very powerful. You can programming, customize or control it as well. The latest Micro:bit V2 board comes with a touchable Logo and microphone on the front. A speaker is added on the back, so all kinds of sounds can be played without external equipment. The gold finger at the bottom adds a gear design to facilitate the user to better fix the alligator clip. In addition, the 2nd generation Micro:bit board also support sleep mode. Users can make it enter sleep mode by long pressing the reset button, which can reduce power consumption. The most important feature is that the CPU performance of the Micro:bit V2 board is much better than the V1 version, coupled with more RAM. So Micro:bit V2 allow users to expand more functions and create more creative works.
0/1
Transfer code to the micro:bit
This guide explains how to transfer code from a computer or tablet so that it can run on a BBC micro:bit. It covers: Transferring a program from MakeCode or the micro:bit Python Editor from a computer from an Apple device (iPad or iPhone) from an Android device Transferring a program that has been downloaded as a file When your program is being transferred, your micro:bit will pause and you may see the yellow LED on the back flash. Once it’s copied across, your program starts running on your micro:bit.
0/6
BASIC LESSONS
Quick projects to suit all ages, searchable by computing topic, level, coding language and micro:bit feature
0/10
SENSOR LESSONS
Quick projects to suit all ages, searchable by computing topic, level, coding language and micro:bit feature
0/8
CREATOR BIT
The micro:bit Creator:bit Bricks Pack contains 360 degrees servos, the LED strips and almost 200 pieces bricks. Together with the well-designed assembly instructions and courses, it makes the kids learn the coding easily as well as how to build blocks in an interesting way. Let’s start building our kits with the tips!
0/9
Private: Welcome to Micro:bit starter kit
About Lesson

Make a real stopwatch using the new micro:bit’s touch logo sensor as an extra button.

Introduction

Coding guide

What you’ll learn

  • How to use the new micro:bit’s touch logo sensor as an extra button in a practical project
  • How to use variables and mathematical operators to measure time
  • How to use mathematical operators to convert units (milliseconds to seconds)
  • What a Boolean variable is and how they can be used to control the flow of a program

How to use it

  • Flash the program onto a new micro:bit with built-in speaker.
  • Press button A to start the stopwatch running. An animated beating heart is shown on the LED display while it’s timing.
  • Press button B to stop it. You can start and stop it as many times as you like and it will keep adding to the time, just like a real stopwatch.
  • Press the gold touch logo on the front of the micro:bit to show the measured time in seconds.
  • To reset the time back to zero, press the reset button on the back of the micro:bit.

How it works

  • The micro:bit tracks how long it’s been powered on in milliseconds (thousandths of a second). This is called the running time.
  • When you press button A, a variable called start is set to the current running time.
  • When you press button B, the start time is subtracted from the new running time to work out how much time has elapsed since you started the stopwatch. This difference is added to the total time, which is stored in a variable called time.
  • If you press the touch logo, the program shows the total elapsed time on the LED display. it converts the time from milliseconds (thousandths of a second) to seconds by dividing it by 1000. It uses the integer division operator to give a result in whole numbers (integers).
  • The program also uses a Boolean variable called running to control the program. Boolean variables can only have two values: true or false. If running is true, the stopwatch has been started. If running is false, the stopwatch hasn’t been started or has been stopped.
  • If running is true, a loop keeps the heart animation appearing on the LED display.
  • It will only show the time when you press the logo if the stopwatch has been stopped, if running is not true.
  • The code prevents false readings by making sure the time variable is only changed when you press button B if the stopwatch has already been started, if running is true.

What you need

  • new micro:bit with sound (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)

Step 2: Code it

MakeCode

 

Step 3: Improve it

  • Modify the program so you can reset the time by shaking the micro:bit.
  • Make the timer more accurate by using fractions of numbers instead of integers (whole numbers).
  • Add a lap time function so that if if you touch the logo while the stopwatch is running it shows the time at that point. Remember to make sure this is not added to the total time variable.