Observing classic social facilitation effects using the Micro:bit in MakeCode

 

This project is built upon classical work by Zajonc (1965), who proposed the idea of social facilitation in sport, where performance in sporting tasks that are familiar to you is improved when you take part alongside others. The actions detected by the ML model will give some rudimentary insight into a player’s level of performance and how that changes through the course of a game of tag. 

Step 1: Make it 

Make a game of tag that draws upon the psychology of exercise and social facilitation using Micro:bit CreateAI 

How it works: 

Variables: 

This project makes use of the following variables: 

  • Praise received - How much praise the player has received from other players 
  • Ready - Has the game started or not  
  • Tagger - If the player is assigned as the tagger or not 
  • Tagger wins - How many times the player has won as a tagger 
  • Waiting - Whether the player is waiting for a response from another player or not. 

The Waiting variable is used when the player is a tagger and is waiting for confirmation from another player that they have been tagged: 

  • The tagger will attempt to tag another player 
  • Then, the Waiting variable is set to 1 
  • If another player has been tagged, the player will respond and set its waiting variable to 0 

Radio signals: 

The project makes use of the Micro:bit’s radio to allow for cross-communication between Micro:bits (for tagging and sending praise). 

All Micro:bits will be assigned to one radio group to ensure they can all communicate with another. 

Additionally, all Micro:bits will have a transmit power of 0 and will detect signal strengths of 1 or lower. This is to ensure Micro:bits can only communicate when they are in close proximity (until about 2 meters apart). 

Data Logging: 

The project also utilises the datalogger extension. Throughout the game each player Micro:bit stores information on the states the player moves through in relation to other variables. Each instance of saved data includes: 

  • The type of movement the Micro:bit detects the player doing (1 column for each type of movement) 
  • The amount of praise the player has recieved so far 
  • The amount of wins the player has amounted as a tagger 

Through analysis of the data you will be able to make rudementary judgements on players’ performance and level of motivation, with praise and win values contextualising players’ movements. 

Machine learning: 

This project involves training a machine learning (ML) model to recognise when a person is doing a variety of actions (standing still, walking, slowly running, and running). 

In order to do this, the model will need to be trained through allowing the Micro:bit to track x, y, and z spatial values while you perform the 4 actions. 

Collect data samples  

Open the micro:bit CreateAI website and create 4 rows of data called ‘Standing still’, ‘Walking’, ‘Slowly running’, and ‘Running’.  

You can add your own movement samples using the micro:bit’s movement sensor or accelerometer. 

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

If using a strap and holder, attach the data collection micro:bit to your left wrist like a watch, with the logo at the top. If not, hold the micro:bit in your left hand with the logo at the top and your thumb on button B. Click on the first action, ‘Standing still’, and click ‘Record’ to record your own data samples. 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. 

If you would like to record continuously for 10 seconds to get 10 samples, click on the three dots next to the record button and select that option. 

Record as many samples as you would like, but 15 samples per actions will suffice. 

Now record your own data samples for the other 3 actions. 

Tip: Consider the many ways in which a person may complete these actions, e.g. for ‘Standing still’ consider that people may stand still with their arms to their sides or folded. 

Train and test the model 

Click the ‘Train model’ button to train the model, then test it. Keep still and see if ‘Staying still’ is estimated correctly. Try the other 3 actions and see if they are estimated correctly as well. Give your micro:bit to someone else to wear (making sure they put it on the same wrist and in the same orientation) and see if it works for them as well. 

Improve the model 

Most models can be improved with more data. If the model needs improving, click on ‘<- Edit data samples’. 

You can delete any data samples which you think don’t fit or add more samples from yourself and other people 

Continue to train the model and test it again 

Integrating the model and coding on your micro:bit 

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

What you need 

  • Atleast 4 micro:bit V2s
  • USB-C to Micro USB Cable 
  • 4 battery packs each with 2x AA batteries 
  • A computer/tablet (e.g. desktop, laptop, or Chromebook) with internet access so you can visit the micro:bit CreateAI website 
  • Load the Datalogger extension into the makecode session. Add via Extensions -> “datalogger” 
  • If your computer does not have Bluetooth enabled, you’ll need an extra micro:bit V2 
  • Optional: At least 3 straps and holders, or another way to attach the micro:bit to your wrist (e.g. flexible craft stems or elastic bands) 

Gather data 

  • Transfer the programs below to your micro:bits. 
  • You can record data anywhere if you unplug a micro:bit from your computer and connect a battery pack 
  • Any previous data is erased when you transfer new code to your micro:bit 
  • You can also download the data as a CSV (comma separated values) file which you can also import into a spreadsheet 

Analyse data 

  • When you’ve collected your data, plug the micro:bit into a computer 
  • The micro:bit appears like a USB drive called MICROBIT 
  • Open the MY_DATA file to see a table of all player data recorded in your web browser 
  • Click download to export the data as a .csv file 

Step 2: Code it 

Starter Micro:bit: 

The starter micro:bit has the role of starting a game of tag as it will assign a tagger and will signal to other micro:bits when a game has started. 

  1. On Start: 

  1. Button A: Assign tagger 

  1. Button B: Start game 

Player Micro:bit: 

The player micro:bits are to be given to each person playing the game of tag and will be responsible for detecting movements from each player, tagging other players, praising other players, and tracking wins and praise in reference to the players’ movements. 

You will need to download this code onto all other micro:bits you intend to use for this project. 

  1. On Start: 

  1. Button A: Tag  

  1. Button B: Send praise 

  1. Buttons A+B: Delete datalog 

  1. On radio received: This is one long block in makecode, represented here in 2 blocks: 

  1. On ML Still: 

  1. On ML Walking: 

  1. On ML Slowly running: 

  1. On ML Running: 

Tag Game Instructions  

You are going to play a game of tag using Micro:bits 

Your aim 

As a tagger – Try to tag another player as quickly as possible 

As a non-tagger – Try to evade being tagged as long as possible  

How the game works 

  • You will be assigned either the tagger or a non-tagger manually by the starter Micro:bit. 
  • When the game begins the tagger should give the players 5 seconds to run away. 
  • When a player is tagged they will be made the new tagger. 
  • You may play for as long as you wish. The more data, the better. 

For starter Micro:bit  

Assigning the tagger (Button A

  • Press A to assign one Micro:bit as a tagger (to do this you will have to manually move one player Micro:bit within range of the starter Micro:bit). 

Starting the game (Button B

  • Press B to start the game of tag (to do this you will need to manually move all player Micro:bits within range of the starter Micro:bit). 

Tagging another player (Button A

  • Press A to attempt to tag a player if they’re in range. 
  • Successful tags will change the tagged player to the tagger and will be tracked as a win. 

Praising another player (Button B

  • Press B to attempt to praise a player if they’re in range. 
  • Successful praises will cause the other player’s Micro:bit to play an animation and sound, as well as increasing their praise received value by 1. 

Delete datalogs (Button A+B

  • Press A+B to delete any logged data stored on the Micro:bit. 

Step 3: Improve it 

  • Consider other ways you could measure motivation. 
  • Adjust sound effects and their volume 
  • Consider more things to be added to the data logger, e.g. times tagged