Category Archives: Sonic Pi

Teaching variables using Sonic Pi in primary classroom coding

Variables are very powerful. They are used in Scratch and can easily be taught through drama.

VARIABLE Life = 5

VARIABLE Points = 0

VARIABLE Game Over = false

IF you get touched, you lose a life

IF you score, you get 1 point

FOREVER (if GAME OVER NOT TRUE) CHECK LIFE & POINTS

IF LIFE = 0, GAME OVER = TRUE, WIN = FALSE

IF POINTS = 10, GAME OVER = TRUE,WIN = TRUE

IF GAME OVER = TRUE, CHECK WIN.

This demonstrates how variables can be used in music using Sonic Pi.