Skip to content

Активност

AI storytelling friend

Средње | MakeCode | Акцелерометар - мерач убрзања, Звучник, Лед екран | Machine learning, Speaking & listening, Understanding AI, Улаз/излаз

A great way to use what children already know about narrative and character development to support new learning about AI.

Step-by-step project guide

Step 1: Understand it

How does it work?

In this project you’ll train a machine learning (ML) model to recognise different ways that you move a soft toy with a BBC micro:bit attached to it. You’ll choose movements to help you retell a story.

You will then combine the machine learning model with a Microsoft MakeCode program, and the micro:bit will play sounds or show images when these movements are detected.

What is machine learning?

Machine learning (ML) is a kind of artificial intelligence (AI) where computers can learn from and make decisions based on data.

ML models are trained by humans to help them make those decisions, for example, to recognise different ‘actions’ when you move your micro:bit in different ways.

What will I need to do?

AI systems need humans to design, build, test, and use them.

First, you will need to decide if you want to use the movements we have provided, or choose different movements that work for your own story. Our story is about a bear called Lucy who wants to be a gymnast, so we have chosen movements that fit this theme: jumping, rollling, and sleeping.

You will then collect data to train the ML model, test it, improve it and combine it with computer code to make a storytelling device that uses AI, using a micro:bit and the micro:bit CreateAI website.

We’ve also included some evaluation questions to compare this AI project with one that just uses normal algorithms and code.

Step 2: Create it

Шта вам је потребно

Collect data samples

When you open the project in micro:bit CreateAI, you’ll see we’ve given you data samples for some suggested movements for your soft toy (jumping, rolling, and sleeping):

You can add your own soft toy movement samples using the micro:bit's movement sensor, its accelerometer.

In micro:bit CreateAI, click the ‘Connect’ button to connect your data collection micro:bit and follow the instructions.

Attach the data collection micro:bit to your soft toy. It’s important that all the samples are recorded with the same placement of the micro:bit on the soft toy. If you want to use the ready-made samples in the project, attach the micro:bit around the neck of the soft toy facing forward, as shown in the picture below. If you want to change how the toy wears the micro:bit, replace all the provided data samples with your own.

A soft toy bear wearing a micro:bit around its neck.

Add your own movement data samples for jumping, rolling and sleeping. Click on each action in turn, then click ‘record’ to take a short sample of each.

If you make a mistake, you can delete any samples you don’t want. You can also press button B on the micro:bit to start recording.

Examine the data samples: do all the ‘jumping’ samples look similar? Do all the ‘rolling’ samples look different to ‘jumping’ and ‘sleeping’?

Train and test the model

Click the ‘Train model’ button to train the model, then test it.

Bounce your soft toy up and down to see if ‘jumping’ is shown as the estimated action. Put the soft toy down to sleep and see if ‘sleeping’ is estimated. Test if ‘rolling’ is detected when you turn the soft toy head over heels.

Ask someone else to move the toy and see if it works as well for them.

Improve your model

Most models can be improved with more data. If the model needs improving to recognise your actions, click on ‘← Edit data samples’.

You can clean your data set by deleting any samples which you think don’t fit (because they look completely different from other samples for the same action). You can also improve the model by adding more samples from yourself and other people.

Think about all the positions your soft toy might ‘sleep’ in, you’ll notice the x, y, and z lines change their order depending on the angle of the micro:bit.

Train the model again, and test it again.

Put the model and code on your micro:bit

In micro:bit CreateAI, click on ‘Edit in MakeCode’ to see the project code in the MakeCode editor.

You can modify the code just like you would in any micro:bit MakeCode project, or just try it out as it is.

Attach a micro:bit using a USB data cable, click on the ‘Download’ button in the MakeCode screen and follow the instructions to transfer your AI model and the code blocks to a micro:bit.

Unplug the micro:bit, attach a battery pack, position it on your soft toy and test it.

How the code blocks work

The 'on ML… start' blocks are triggered when the ML model decides your toy has started one of the actions it has been trained to detect. Different sounds play and different icons are shown on the micro:bit's LED display depending on the action it has estimated your soft toy is doing.

The 'on ML… stop' blocks are triggered when the ML model decides your toy has finished an action. Code inside each block clears the screen and stops all sounds.

An extra block, ‘on ML unknown start’, clears the screen if the model is not sure which action your toy is doing.

Evaluation

Compare this project with the Sensory toy project that also uses the accelerometer sensor to react to different movements but which does not use machine learning or any other kind of AI.

  • What kinds of movements, or actions, can the Sensory toy project react to?
  • What is different about the kinds of actions the AI storytelling friend project can react to? Are they simpler or more complex?
  • What other actions might you want to train the ML model to recognise?
  • Which project is better at helping you tell your story?

Step 3: Extend it

  • Explore different movements with your AI storytelling friend, and change the actions to suit a well-known folk story or fairytale.
  • Use the ‘show LEDs’ block in place of the ‘show icons’ block to customise the icons to match your story. You could plan your customised icons using the LED planning sheets.
  • If you have a class mascot, use CreateAI to train the mascot to respond to movements that give feedback to students e.g. give praise or reward class points.