To create your simple AI exercise timer,  you’ll train a machine learning (or ML) model. This model will recognise when you’re  exercising and when you’re not exercising. You’ll then combine the model with some  ready-made code for an exercise timer... before downloading it to your  micro:bit and using it in real life. Click ‘Open in micro:bit CreateAI’ to launch the project. The project comes with 3 samples  of movement data for exercising and 3 samples of movement  data for not exercising. You’ll need to add more samples by  recording your own movement data. micro:bit CreateAI collects movement  data samples using the accelerometer (or movement sensor) on the micro:bit. You will wear a micro:bit and battery pack on your wrist or ankle, so that you can move  freely to record your own movement data samples. To get started, you need to set  up the data collection micro:bit. Connect the wrist-worn micro:bit to CreateAI. If your computer has Bluetooth enabled then you will just need 1 micro:bit and a USB data lead. If you don’t have a Bluetooth connection, you’ll be prompted to use 2 micro:bits. The second micro:bit will remain connected to the USB cable and act as a radio  link to the data collection micro:bit. Follow the instructions on screen to connect. Once your data collection micro:bit is connected you’ll see the lines on the live graph  change as you move your micro:bit about. You’re now ready to add your  own movement data samples. As this project already includes some  data samples, we suggest you just add 1 more sample for each action for now, and spend  more time collecting and analysing data later. Decide what ‘exercising’  action you are going to do. This could be running, walking briskly,  jumping, boxing, dancing, or any other exercise. Make sure the micro:bit is attached to  the wrist or ankle that will be moving. To add data to a specific action,  select it by clicking on it. You will get a 3 second countdown  before a 1 second recording starts. Click record and start moving right away  to ensure you get a clean data sample. A clean sample is one where you  are moving for the entire sample, you don’t start late or finish moving early. Next try adding an extra data sample to the ‘not exercising’ data set. Select it by clicking on the action, then stay still, or only move very  slightly as you record the sample. You’ll notice that the x,y,z  lines change places depending on the angle at which you hold your micro:bit. The project doesn’t have a lot of data right now, but we have enough to train our own  machine learning model using CreateAI. So click ‘Train’ to use the  current data to build an ML model. The tool now builds a mathematical  model that should recognise different actions when you move your micro:bit. As soon as the model has been trained, you’ll see the Testing model page. Your data collection micro:bit can now be used to test how well the model is working. 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. Try out different levels of exercising or  not exercising to see both the estimated action and the certainty bar graph change. The % on the certainty bar graph shows how confident the model is that  you are doing each action. You may notice your model is not estimating  some actions accurately, or maybe it is working well for one action but not the other, so after exploring how it is currently working, it’s a good idea to click on ‘Edit  data samples’ and improve your model. Machine learning models usually work best with  more data, so record some extra samples for each of the actions, or focus on collecting more data  for the action that was problematic in testing. You can record 1 sample at a time or  you can record 10 samples in sequence. Clean data samples also  help an ML model work better so interrogate your data set and identify any  data samples that could confuse the model. You can delete these by pressing x. Once you’ve added more data and checked your data set, click Train model  again to use your amended data set. Then test the model again on  the ‘Testing model’ page. Once you’re happy with how  the ML model is behaving, you can use it with the ready-made project code. Click on 'Edit in MakeCode' to see the code blocks  in a special version of Microsoft MakeCode. You can always return to CreateAI using  the arrow in the top left of the screen. These code blocks use the model you  have created within an exercise timer. The code uses two variables to keep track  of how long you've been exercising and how long you've not been exercising. When the program first runs it sets these timer variables to 0. The 'on ML start' blocks are triggered when the ML model decides you have  started either exercising or not exercising. They show different icons on the  micro:bit's LED display depending on the action it has estimated you are doing. The 'on ML stop' blocks are triggered when the ML model decides you have finished an action,  in this case exercising or not exercising. Code inside each block clears the screen and  adds the duration of the action that has just finished to the variable storing  the total times for each action. The ML model works with the code to allow you  to view the total time spent on each action. Press button A to see the total time you have  been exercising and press button B to see the total time you have been inactive. The timer counts in milliseconds, thousandths of a second, so the number shown  is divided by 1000 to show a time in seconds. To make your simple AI exercise  timer run on your micro:bit, you just need to download this code to a micro:bit. If you don’t have another micro:bit available, simply replace the code currently on the data  collection micro:bit with the project code. Now test the project out in real life. Do the correct icons display when you are exercising or not? You can test if the timer code is working well with the model in 3 easy steps: Press the reset button. Exercise for 30 seconds. Then press button A. You should see the number 30  scroll across your display. You’re now ready to connect to CreateAI,  collect your own data, use it to train, test & improve a machine learning model. And you can then combine this model with the ready-made code and try  it out on your own micro:bit.