Play a single MIDI note
# play middle c for 1 second
speaker.play(60)
lightbulb Note names
Notes go from 0 (low) to 127 (high).
bug_report My note doesn't sound right
-
Make sure you are not using a number higher than
127. -
Make sure you have imported the
Speaker. -
Make sure you have set the pin number for the
Speaker.
Play multiple notes
# Ta-Daaa!
speaker.play(60, 0.1) # short c note
sleep(0.1) # rest
speaker.play(60, 0.4) # long c note
lightbulb Note length
The default length is 1 second. Specify a different length with a number.
lightbulb Use a rest
A rest is a short break in the tune. If you don't add in a rest then the notes can blend into one.