View on GitHub

makecode-BART

BART task for the micro:bit

Recreating the Balloon Analogue Risk Task for the Micro:bit in MakeCode

BART Balloon BART Pop

The Balloon Analogue Risk Task (BART) is a measure of risk taking propensity. Participants engage in a risk taking task in order to recieve a hypothetical reward. The riskier a participant acts, the higher the potential gains but also the higher potential for losses.

The BART involves blowing up a balloon via individual pumps. After each pump, a participant can choose to bank some money/points. As the balloon size increases, the money/points which can be banked increases. However, the balloon can pop after any pump, resulting in no money/points being banked for that balloon. Participants are therefore required to pump the balloon to as large a size as they can, without popping it, in order to bank the most money/points. However, the probability of popping the balloon increases with every pump, making it a gamble to grow the balloon to a large size.

Completing the BART task once in a laboratory setting is often considered a valid measure of someones trait-level risk taking. In other words a persons stable propensity to engage in risky behaviours across situations and time. However, recent work has suggested that their might be intraindividual variability in someones risk taking behaviours; meaning that peoples risk taking propensity might actually change across time and situations (see doi: 10.1007/s10862-017-9628-4, or click here! )

To test this, a mobile version of the BART task is needed, that can be completed ‘on-the-go’. It is possible that the micro:bit can be a portable alternative to lab based assessments of the BART.

Step 1: Make it

A micro:bit compatible version of the BART can be found here: https://github.com/h-shawberry/makecode-BART

In this tutorial, we will be building this BART task in MakeCode.

How it works:

Variables:

The programme uses several variables to store important information:

For example, when Pause = true, the micro:bit ignores the A and B buttons — this happens when:

When Pause = false, the player can pump and bank again.

Therefore, the Pause variable stops the player from pressing buttons during important moments and keeps the game running smoothly.

Data Logging:

The programme also utilises the datalogger extension. At the end of the game it stores information on how the player interacted with the game so their level of risk can be analysed and compared to other players. The data saved includes:

Apart from the number of rounds, the above data are all indicators of risk taking propensity.

Forever Loop:

The programme also uses a forever loop to constantly check:

if…else statements:

To show the balloon growing on the LED screen, the micro:bit uses a long chain of if… else statements.

This means:

Each balloon level also plays a different musical note, so the balloon looks and sounds like it’s growing.

This is how the micro:bit knows exactly which picture to show at each moment.

Functions:

The programme uses functions to avoid duplicate block code.

FullReset()

Sets everything back to the beginning of the game:
balloon size = 0, pumps = 0, pops = 0, round = 1, Pot = 0, new random pop point.

Instructions()

Shows the player what the game looks like — a growing balloon animation, and the words Pump and Bank with arrows indicating which button to press for each.

RoundEnd()

Starts the next round:
balloon goes back to size 0, and a brand‑new secret pop number is chosen.

showBallonLevelLED()

Shows different balloon shapes on the LEDs depending on how many pumps have happened. It also plays higher and higher musical notes as the balloon grows!

HappyEnd()

Runs when the whole game is finished:
Shows your total points, logs results, and then resets the game.

What you need

Gather data

Analyse data

Screenshot of micro:bit data log page

Step 2: Code it

1) Function: FullReset()

FullReset function blocks

2) Function: Instructions()

Instructions function blocks

3) Function: RoundEnd()

RoundEnd function blocks

4) Function: showBallonLevelLED() This is one long block in makecode, represented here in 2 columns:

First column of showBallonLevelLED blocks Second column of showBallonLevelLED blocks

5) Function: HappyEnd()

HappyEnd function blocks

6) Button A: Pump

Button A pump logic

7) Button B: Bank

Button B bank logic

8) Forever Loop:

Forever loop logic

9) On Start:

On start logic

Step 3: Improve it:

Random range settings to adjust difficulty

Balloon Game Instructions

You are going to play a balloon‑pumping game using the micro:bit.

Your aim

Try to collect as many points as you can.
The more you pump, the more points you might earn —
but pump too much and the balloon might pop!

How the game works

Pumping the balloon (Button A)

Banking your points (Button B)

If the balloon pops:

When the game ends