Skip to the content.

Head or tail icon

Head or tail MicroCode program

Flip a virtual coin and show head or tail when the micro:bit is shaken.

The program starts with a rule that uses a shake event and 2-face dice is cast. The result is stored in variable X.

when shake, set variable X to random number up to 2

when shake, play an arpeggio

The next 2 rules match the value passed in variable X and display a different symbol for each value, 1 or 2.

when variable X changed to 1, show head

when variable X changed to 2, show tail

improvement ideas

Video