Project 19 of 35  ·  Scratch Programming  ·  Module 1
Module 1

Rock Band

Create a playable musical ensemble with four instruments triggered by keys and clicks.

🍓  Open on Raspberry Pi Projects  ↗ Opens the official Raspberry Pi Foundation project — includes starter files and full step-by-step guide

What You Will Build

Create a playable musical ensemble with four instruments triggered by keys and clicks. Follow the guide below to build the project, then open the official Raspberry Pi page for starter files, worked examples and extra help.

🍓 This project is on the Raspberry Pi Foundation website. Click the orange button above to access the full guide, starter Scratch project and extension activities on projects.raspberrypi.org.

What You Will Learn

  • Assign keyboard keys to trigger different instrument sprites
  • Use the Music extension to play instrument-specific drum or note sounds
  • Animate each instrument with a playing and idle costume
  • Record a performance to a list and play it back
  • Add a conductor that shows which instrument to play next

Step-by-Step Guide

  • 1Add a stage backdrop and 4 instrument sprites: guitar, drums, keyboard, bass.
  • 2Each sprite has 2 costumes: idle and playing.
  • 3Guitar: when [a] pressed → switch to playing costume → play guitar sound → switch back.
  • 4Drums: when [s] pressed → playing → drum sound → idle.
  • 5Keyboard: when [d] pressed → playing → piano note → idle.
  • 6Bass: when [f] pressed → playing → bass note → idle.
  • 7Add a beat variable that increases by 1 every second on a timer.
  • 8Add a record list. When record is true, add each key pressed with its timestamp.
  • 9Play button: loop through the list and trigger each instrument at the right beat timing.
  • 10Add a conductor sprite that shows which instrument should play using a pattern variable.

Extension Challenges

Finished the main project? Push further:

  • Add stage lights that flash in sync with each instrument hit.
  • Create a setlist of 3 different rhythm patterns the band can play.
  • Add a second player mode using different keys (j, k, l, ;) for competition.