Sunteți pe pagina 1din 17

Name:________________

Form:______
Raspberry Pi Setup
1. Connect Monitor:
Use the HDMI to DVI lead
to connect the monitor.
2. Connect Inputs:
Plug the mouse and
keyboard into the USB ports.
3. Connect Headphones:
Plug in the headphone.
4. Connect Power:
Connect the power
adapter, plug it into
the wall socket and
switch it on.
Raspberry Pi Setup
Once your Raspberry Pi has started up you will
need to login with these details:
Login: pi
Password: raspberry
Now type startx to load the GUI (graphical user
interface).
Open Sonic Pi:
(Start > Programming > Sonic Pi)
Sequencing
A computer works by executing instructions one
after another in a specific order (or sequence).
A sequence of instructions is called a program.
Type in this sequence of
instructions and test it.
play 60
sleep 1
play 61
sleep 1
play 62
sleep 1
play 63
sleep 1
play 62
sleep 1
play 61
sleep 1
play 60
Notes
Each number represents a
different musical note.
Task 1
Write a sequence of instructions that will play this
song:
Write down your completed code below:
Shutting Down
You need to make sure you shutdown your
Raspberry Pi properly otherwise you could damage
it.
Exit the GUI:
(Start > Logout)
At the command line type:
sudo halt
Homework 1
Debug this program by highlighting and
annotating the errors:
play 37
sleap 2
pllay 49
sleap 2
pay 49
Write a sequence of instructions that will play 6
notes with a 2 second delay between each one:
Loops
Sometimes we need to repeat the same set
instructions several times. For this we can use a
loop.
Type in this sequence of
instructions and test it.
5.times do
play 42
sleep 0.5
play 45
sleep 0.85
play 54
sleep 1
play 54
sleep 0.7
play 45
sleep 0.2
play 49
sleep 1
end
Change the program so that it
repeats 10 times.
Task 2
Write a sequence of instructions that plays this
song, making use of loops for sets of notes that are
repeated.
Write down your completed code below:
Homework 2
Write a set of instructions that plays 10 notes that
loop 3 times.
Lists
Rather than writing out each note on a separate
line you can use a list.
Type in this instruction and test it.
play_pattern [40,25,45,25]
Now type in this instruction and test it.
play_pattern [40,25,45,25], [1, 1, 1, 1]
What is the difference?
Task 3
Write a program to play this song making use of
lists and loops:
Write down your completed code below:
Task 4
Write a program to play this song making use of
lists:
Write down your completed code below:
Task 5
Write a program to play this song:
Homework 3
Write a set of instructions that plays a list of notes,
with a 2 second delay between each one and
repeats them 3 times.
Extension
Find the music for another song and write a
program to play it. Write your code below:

S-ar putea să vă placă și