The MIDI Code Detective Challenge

Learn to edit CircuitPython MIDI code step by step

Connect your MIDI device to start the challenge
Challenge 1 of 4
Challenge 1: BEGINNER
Change One Note
Learn the basics of editing MIDI note values

Your Goal: Play Middle C (C4)

C4 (60)

Touch your first sensor to play Middle C

Step-by-Step Instructions:
1 Connect your CircuitPython device to your computer via USB
2 Open File Explorer and find the CIRCUITPY drive
3 Right-click on code.py and select "Open with Notepad"
4 Find the line that says: midi_notes = [98, 96, 93, 91, ...]
5 Change the first number from 98 to 60
6 Save the file (Ctrl+S) and test your first touch sensor
# Original code:
midi_notes = [98, 96, 93, 91, 88, 86, 84, ...]
# Change to:
midi_notes = [60, 96, 93, 91, 88, 86, 84, ...]
Hint: MIDI note 60 is Middle C (C4). Your device currently starts with note 98 which is D7 - much higher! Look for the very first number in the square brackets.
Edit your code.py file and touch your first sensor!
Challenge 2: INTERMEDIATE
Create a C Major Scale
Set up multiple sensors to play a musical scale

Your Goal: Create C Major Scale

C4
D4
E4
F4
G4

Program your first 5 sensors to play C-D-E-F-G

Step-by-Step Instructions:
1 Open code.py in Notepad again
2 Find the midi_notes = [...] line
3 Change the first 5 numbers to: 60, 62, 64, 65, 67
4 Save the file and test all 5 sensors in order
# Change from:
midi_notes = [60, 96, 93, 91, 88, 86, 84, ...]
# Change to:
midi_notes = [60, 62, 64, 65, 67, 86, 84, ...]
Hint: C Major scale notes: C(60), D(62), E(64), F(65), G(67). Each step up the scale adds 1 or 2 to the MIDI number following the pattern: +2, +2, +1, +2.
Program your scale and play it in sequence!
Challenge 3: ADVANCED
Decode the Mystery Melody
Figure out the MIDI numbers for a famous tune

Mystery Melody: "Twinkle, Twinkle, Little Star"

C4
C4
G4
G4
A4
A4
G4

Program the first 7 sensors to play this tune

Step-by-Step Instructions:
1 Open code.py in Notepad
2 Look up the MIDI numbers: C4=60, G4=67, A4=69
3 Set the first 7 numbers to match the melody pattern
4 Play the sensors in order to hear the tune
# Set the first 7 numbers to:
midi_notes = [60, 60, 67, 67, 69, 69, 67, ...]
# This plays: C C G G A A G
Hint: "Twinkle Twinkle Little Star" goes: C-C-G-G-A-A-G. In MIDI numbers that's: 60-60-67-67-69-69-67. Notice how some notes repeat!
Decode the melody and play the tune!
Challenge 4: EXPERT
The Mystery Hit
Program this famous melody - can you guess what song it is?

Mystery Song - Opening Melody

A4
B4
D5
B4
F#5
F#5
E5
A4

Program the first 8 notes of this iconic song!

Step-by-Step Instructions:
1 Open code.py in Notepad
2 Look up the MIDI numbers: A4=69, B4=71, D5=74, E5=76, F#5=78
3 Set the first 8 numbers to match the mystery melody
4 Play the sensors in order to reveal the song!
# Set the first 8 numbers to:
midi_notes = [69, 71, 74, 71, 78, 78, 76, 69, ...]
# This plays: A B D B F# F# E A
# Can you guess the song?
Hint: The melody pattern is A-B-D-B-F#-F#-E-A. In MIDI numbers: 69-71-74-71-78-78-76-69. This is a very famous song from the late 1980s!
Program the mystery melody and discover the song!
Congratulations!

You've mastered the art of MIDI code editing! You can now modify CircuitPython code to create any musical experience you can imagine.

MIDI Note Reference Chart

Use this chart to convert between note names and MIDI numbers:

C3
48
C4
60
C5
72
D4
62
E4
64
F4
65
G4
67
A4
69
B4
71

Pro Tip: Each octave adds 12 to the MIDI number. C4=60, so C5=72, C6=84, etc.

0
Skip to Content
SPOKE
Home
Play
Build
Code
Learning
Built-With-SPOKE
DIY
Contact
SPOKE
Home
Play
Build
Code
Learning
Built-With-SPOKE
DIY
Contact
Home
Play
Build
Code
Learning
Built-With-SPOKE
DIY
Contact