< Return to Video

AI activity timer step-by-step video

  • 0:01 - 0:08
    To create your AI activity timer, you 
    will train a machine learning, or ML, model
  • 0:08 - 0:13
    to recognise when you’re doing 
    different movements or activities.
  • 0:13 - 0:19
    You’ll then combine that model with some 
    ready-made code for an activity timer,  
  • 0:19 - 0:27
    before downloading it to your 
    micro:bit and using it in real life.
  • 0:27 - 0:34
    Click ‘Open in micro:bit CreateAI’ to launch the project.
  • 0:34 - 0:41
    This project comes with 6 samples of movement 
    data for walking, 6 samples of movement data  
  • 0:41 - 0:47
    for jumping up and down, and 6 samples of 
    movement data for staying fairly still.
  • 0:47 - 0:54
    You will add more samples by 
    recording your own movement data.
  • 0:54 - 1:03
    micro:bit CreateAI collects movement data
    samples using the accelerometer,  
    or movement sensor, on the micro:bit.
  • 1:06 - 1:10
    You will wear a micro:bit and battery pack on your wrist or ankle
  • 1:10 - 1:15
    so that you can move freely
    to record your own movement data samples.
  • 1:15 - 1:20
    To get started, connect the 
    ankle-worn micro:bit to CreateAI. 
  • 1:20 - 1:24
    We call this the data collection micro:bit.
  • 1:24 - 1:32
    If your computer has Bluetooth enabled then you will just need 1 micro:bit with a battery pack and a USB data lead.
  • 1:32 - 1:37
    If you don’t have a Bluetooth connection, 
    you’ll be prompted to use 2 micro:bits.
  • 1:37 - 1:41
    The second micro:bit will remain 
    connected to the USB cable and act as  
  • 1:41 - 1:51
    a radio link to the data collection micro:bit.
    Follow the instructions on screen to connect.
  • 1:51 - 1:58
    Once your micro:bit is connected, you will see the lines on the live graph change as  you move your micro:bit about.
  • 1:58 - 2:02
    You’re now ready to add your own movement data samples.
  • 2:02 - 2:06
    As this project already includes some data samples,
  • 2:06 - 2:17
    we suggest you just add 1 more sample for each action for now, and spend more time collecting and analysing data later.
  • 2:17 - 2:25
    Make sure your data collection micro:bit is attached to the inside of the ankle, with button B on top.
  • 2:25 - 2:29
    To add data to a specific action, 
    select it by clicking on it. 
  • 2:29 - 2:34
    You will get a 3 second countdown 
    before a 1 second recording starts. 
  • 2:34 - 2:40
    Click record and start moving right away 
    to ensure you get a clean data sample. 
  • 2:40 - 2:44
    A clean sample is one where you 
    are moving for the entire sample,  
  • 2:44 - 2:49
    you don’t start late or finish moving early.
  • 2:49 - 2:56
    Next try adding an extra data sample to the ‘jumping’ data set and the ‘being still’ data set.
  • 2:56 - 3:05
    Select them by clicking on the action, then click record and jump or stay quite still as you record the samples. 
  • 3:05 - 3:17
    You’ll notice on the 'being still' samples 
    that the x,y,z lines change places depending on the angle of the attached micro:bit.
  • 3:17 - 3:26
    We don’t have a lot of data right now, but we do have enough to train our own  machine learning model using CreateAI. 
  • 3:26 - 3:34
    So click ‘Train model’ to use the 
    current data to build an ML model.
  • 3:34 - 3:41
    The tool now builds a mathematical model that should recognise different actions when you move your micro:bit.
  • 3:41 - 3:46
    As soon as the model has been trained, you will see the Testing model page.
  • 3:46 - 3:51
    Now use the data collection micro:bit to test how well the model is working.
  • 3:51 - 4:00
    It should still be connected to the tool, and you’ll see that as you move it, CreateAI is estimating what action you are doing.
  • 4:02 - 4:10
    Try out each of the actions to see 
    both the estimated action and the certainty bar graph change.
  • 4:11 - 4:19
    The % on the certainty bar graph shows how confident the model is that you are doing each action. 
  • 4:22 - 4:27
    You may notice your model is not estimating 
    some actions accurately, or maybe it is  
  • 4:27 - 4:33
    working well for one action but not the other, 
    so after exploring how it is currently working,  
  • 4:33 - 4:40
    it is a good idea to click on ‘Edit 
    data samples’ and improve your model. 
  • 4:40 - 4:46
    Machine learning models usually work best with 
    MORE data, so record some extra samples for each  
  • 4:46 - 4:55
    of the actions, or focus on collecting more data 
    for the action that was problematic in testing. 
  • 4:55 - 5:02
    You can record one sample at a time or 
    you can record 10 samples in sequence. 
  • 5:10 - 5:23
    Clean data samples also help an ML model work 
    better so examine your data set and identify any data samples that could confuse the model.
  • 5:26 - 5:30
    You can delete these by pressing X.
  • 5:31 - 5:39
    Once you’ve added more data and checked your data set, click ‘Train model’ again to use your amended data set. 
  • 5:40 - 5:46
    Then test the model again on the ‘Testing model’ page.
  • 5:49 - 5:55
    Once you’re happy with how the ML model is behaving, you can use it with the ready-made project code. 
  • 5:55 - 6:02
    Click on ‘Edit in MakeCode’ to see the code 
    blocks in a special version of Microsoft MakeCode. 
  • 6:02 - 6:10
    You can always return to CreateAI using 
    the arrow in the top left of the screen. 
  • 6:10 - 6:19
    These code blocks use the model you 
    have created within an exercise timer. 
  • 6:19 - 6:26
    The code uses 3 variables to keep track 
    of how long you've been doing each action. 
  • 6:26 - 6:34
    When the program first runs it 
    sets these timer variables to 0. 
  • 6:34 - 6:40
    The 'on ML start' blocks are triggered when the ML 
    model decides you have started a specific action. 
  • 6:40 - 6:49
    They show different icons on the micro:bit's LED display depending on the action it has estimated you are doing.
  • 6:50 - 7:01
    The 'on ML stop' blocks are triggered when the ML model decides you have finished an action, 
    in this case walking, jumping or being still. 
  • 7:01 - 7:07
    Code inside each block clears the screen and 
    adds the duration of the action that has just  
  • 7:07 - 7:13
    finished to the variable storing 
    the total times for each action. 
  • 7:13 - 7:19
    The ML model works with the code to allow you 
    to view the total time spent on each action. 
  • 7:19 - 7:23
    Press button A to see the estimate 
    of how long you were walking. 
  • 7:23 - 7:28
    Press button B to see how long the 
    model estimated you were jumping. 
  • 7:28 - 7:34
    To see the estimated duration you have 
    been still press A and B together. 
  • 7:34 - 7:44
    The timer counts in milliseconds, thousandths of a second, so the number shown is divided by 1000 to show a time in seconds.
  • 7:44 - 7:53
    To make your AI activity timer run on your micro:bit, you just need to download this code to a micro:bit. 
  • 7:53 - 8:01
    If you don’t have another micro:bit available,
    simply replace the code currently on the data collection micro:bit with the project code.
  • 8:02 - 8:05
    Now you can test the project out in real life.
  • 8:05 - 8:10
    Do the correct icons display 
    when you are exercising or not? 
  • 8:10 - 8:16
    You can test if the timer code is working 
    well with the model in 3 easy steps:
  • 8:16 - 8:19
    Press the reset button.
    Jump for 30 seconds.
  • 8:19 - 8:26
    Then press button B.
    You should see the number 30 scroll across your display.
  • 8:26 - 8:29
    You’re now ready to connect to CreateAI,  
  • 8:29 - 8:35
    collect your own data, use it to train, test and 
    improve a machine learning model, and then you  
  • 8:35 - 8:41
    can combine this model with the ready-made 
    code and try it out on your own micro:bit. 
  • 8:41 - 8:48
    If you’re looking for ways to personalise this even more try adding some different actions like running or dance steps.
  • 8:48 - 8:52
    Enjoy!
Title:
AI activity timer step-by-step video
Description:

more » « less
Video Language:
English
Team:
Microbit_Educational_Foundation
Duration:
08:53
Microbit_Educational_Foundation edited English subtitles for AI activity timer step-by-step video

English subtitles

Revisions