-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtune.py
More file actions
22 lines (20 loc) · 1.33 KB
/
tune.py
File metadata and controls
22 lines (20 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
This demo requires a speaker connected to P0 and GND
"""
import microbit
# play Bach Prelude in C.
notes = [
'c4', 'e4', 'g4', 'c5', 'e5', 'g4', 'c5', 'e5', 'c4', 'e4', 'g4', 'c5', 'e5', 'g4', 'c5', 'e5',
'c4', 'd4', 'g4', 'd5', 'f5', 'g4', 'd5', 'f5', 'c4', 'd4', 'g4', 'd5', 'f5', 'g4', 'd5', 'f5',
'b3', 'd4', 'g4', 'd5', 'f5', 'g4', 'd5', 'f5', 'b3', 'd4', 'g4', 'd5', 'f5', 'g4', 'd5', 'f5',
'c4', 'e4', 'g4', 'c5', 'e5', 'g4', 'c5', 'e5', 'c4', 'e4', 'g4', 'c5', 'e5', 'g4', 'c5', 'e5',
'c4', 'e4', 'a4', 'e5', 'a5', 'a4', 'e5', 'a4', 'c4', 'e4', 'a4', 'e5', 'a5', 'a4', 'e5', 'a4',
'c4', 'd4', 'f#4', 'a4', 'd5', 'f#4', 'a4', 'd5', 'c4', 'd4', 'f#4', 'a4', 'd5', 'f#4', 'a4', 'd5',
'b3', 'd4', 'g4', 'd5', 'g5', 'g4', 'd5', 'g5', 'b3', 'd4', 'g4', 'd5', 'g5', 'g4', 'd5', 'g5',
'b3', 'c4', 'e4', 'g4', 'c5', 'e4', 'g4', 'c5', 'b3', 'c4', 'e4', 'g4', 'c5', 'e4', 'g4', 'c5',
'b3', 'c4', 'e4', 'g4', 'c5', 'e4', 'g4', 'c5', 'b3', 'c4', 'e4', 'g4', 'c5', 'e4', 'g4', 'c5',
'a3', 'c4', 'e4', 'g4', 'c5', 'e4', 'g4', 'c5', 'a3', 'c4', 'e4', 'g4', 'c5', 'e4', 'g4', 'c5',
'd3', 'a3', 'd4', 'f#4', 'c5', 'd4', 'f#4', 'c5', 'd3', 'a3', 'd4', 'f#4', 'c5', 'd4', 'f#4', 'c5',
'g3', 'b3', 'd4', 'g4', 'b4', 'd4', 'g4', 'b4', 'g3', 'b3', 'd4', 'g4', 'b4', 'd4', 'g4', 'b4'
]
microbit.music.tune(microbit.pin0, notes)