Professional Documents
Culture Documents
magpi-eduedition01
magpi-eduedition01
EDUCATOR
’S
EDITION
RASPBERRY PI
FOR
EDUCATION
FIND OUT HOW THE RASPBERRY PI FOUNDATION HELPS EDUCATORS
AROUND THE WORLD TEACH COMPUTING IN SCHOOLS
CEO Philip Colligan introduces the UK tech 03 learners and educators all over
the world. Learn more here…
coding projects from around the
country found their way onto the ISS
charity, the Raspberry Pi Foundation
WELCOME
TO THE RASPBERRY PI
COMMUNITY
Find out how the Raspberry Pi Foundation
supports a global community of educators
and how you can get involved.
DIGITAL
MAKING
REVOLUTION
IN EDUCATION
The digital maker movement, a mix of traditional artisan arts and crafts
combined with computer programming and electronics, has been taking
the world by storm. Its ethos of tinkering and inventing is being used
in the classroom to inspire a whole new generation of makers.
Making lessons more engaging
and relevant for learners
Raspberry Pi computers, and other similar devices,
are unlike the traditional computers you would find
in classrooms up and down the country. Rather than
a hermetically sealed box, designed specifically to
prevent a student from poking and prodding around
with the internal components, you are presented
with a single board computer with all the parts
exposed. This design decision is not an accident:
We want to demystify computers, to allow children
to see that there is nothing to be afraid of, to show
them exactly where the operating system can be
found, and to let them experiment with controlling
electronics using the General-Purpose Input/Output
(GPIO) pins.
HACKATHONS The design also poses questions for teachers who
wish to deploy Raspberry Pi computers in their
Hackathons are events at which groups of individuals will build a classrooms. Do you have them as fixed pieces of
digital product from scratch, often over a single twenty-four hour equipment, permanently attached to power supplies,
period. Fuelled by pizza and cola, as well as by their own enthusiasm, keyboards and mice? Do you use cases, and, if so,
students can work together to build anything from internet-connected which one? Do you give students their own SD card, or
Christmas trees to the next great social networking app. The events should they share? How do you keep the software up-
are competitive but very supportive, and always lots of fun. to-date and ensure that students can always access
Hackathons are a great way to encourage creativity, problem- their work?
solving and teamwork within the sphere of computing and digital These are all natural concerns, especially if you
making. There are plenty of student hackathons organised all over come from a traditional teaching background, but
the country, and mlh.io is a good place to start if you’re looking maybe the first question you should be asking yourself
for an event near you. is: How do I make computing more engaging and
relevant for my students?
MANY
USEFUL
IDEAS
“Picademy’s
Continuing
Professional
Development
was excellent
and it gave me
many useful
PICADEMY:
ideas to go back
to school with,
particularly the
use of Minecraft
Pi. It was a great
experience to
spend time with
like-minded
people who
could see how
itching a ride on a Soyuz second day the teams launched It’s really important to us that
H rocket is not the only way
to get a Raspberry Pi into
their own payloads following
a demo launch by seasoned
it’s not just a bit of fun for a few
days, it’s a great opportunity to
ANATOMY
OF A FLIGHT
the stratosphere. High Altitude professional Dave Akerman. Our explore the power of project- > A large helium
Ballooning involves sending a educators then had the task of based learning using a range of balloon lifts a
small electronic device or ‘tracker’ tracking their flight by car in the disciplines including science, small (<500g)
payload up to
into the upper atmosphere using a hope of recovering their payload technology, engineering, and 35km, where the
meteorological balloon. That’s what as it landed. The payloads reached computer science.” balloon bursts.
our recent Skycademy course was heights of around 35km, capturing We’ve since seen several > After the burst,
all about: a Picademy designed to images throughout their flight. launches by our educators, the payload falls
show educators how to deliver their At the apex people could view the including a flight from PyCon UK using a small
parachute to
own near space project. curvature of the Earth and the in which teachers sent trinkets like slow its descent.
James Robinson, who leads the black of space! Lego figures up with the payload.
> The payload
project, explains: “Having run a Bourne Grammar School ran our contains a
[HAB] launch myself in school, I’d Skycademy Continues first entirely student-led flight, flight computer
seen how engaged and inspired my Skycademy wasn’t just those three with pupils managing everything (Raspberry Pi)
connected to a
students were, seeing that reaching days though, the attendees will including the chase and recovery. GPS antenna, a
near space was within their grasp. report back over the next several Glebe House School captured radio transmitter
We wanted to share that experience months about their own launches. amazing images of the Norfolk and camera.
with other educators and, while the James explains: Coast during their flight. > The payload
project involves several disciplines, “The event marks the beginning We’re looking forward to seeing continually
collects GPS
getting to grips with each is not of a year-long project where what the rest of our educators do data and images
too difficult.” The initial goal was we’ve funded each of the newly- over the coming year. To find out and transits
simple: give some enthusiastic qualified educators to run a launch more about Skycademy, visit them via its
radio.
educators the hands-on experience themselves with their students. rpf.io/skycademy.
>O
n the ground
and confidence to do their own
listeners can
supervised launch, and then hope receive the GPS
they return to their students fired data and use it
to predict the
up to run their own projects.
landing site.
Teacher Training
After juggling the places and
managing a waiting list, on 24
August 2015, four teams of six
teachers from around the UK met
Left High above
to begin their training. Over three
the Earth, our
days the teams learned how to intrepid weather
balloons take
build, configure, and track their
shots of the
High Altitude payload. On the world below
ASTRO PI:
Peake in early January.
FOLLOW US
ONLINE
YOUR CODE IN SPACE
The Astro Pi units Find out how your students can code software for British ESA
will remain on the
ISS until 2022 and Astronaut Tim Peake to use on the International Space Station
we hope to run
many more Astro
Pi competitions,
What is Astro Pi? Tim Peake to run aboard the Python programs, written and tested
challenges, If you’re looking for a way to International Space Station (ISS). by the school pupils using their own
and interactive inspire your students to learn Two augmented Raspberry Sense HAT boards and Raspberry
activities
about computer programming you Pi computers (called Astro Pis) Pis. The winning programs, now
between now
and then. If you won’t struggle to get them excited have been flown to the ISS as the part of the Astro Pi payload, blasted
follow us on about this! Simply say: “Do you platform on which to run these off from Cape Canaveral Air Force
social media
want your code in space?” and experiments. They include a Base in Florida back in December
you can keep
up to date on watch as their mouths hang open special sensor board, a Raspberry and arrived at the ISS a few days
everything that while they take in the scope of Pi peripheral called the Sense HAT. before Tim. They range from fun
is happening!
what you just said. This can measure the environment reaction time games to serious
Twitter Computer programming is inside the ISS, detecting how science experiments looking
@astro_pi an incredibly important skill the station is moving through at space radiation.
@astro_pi_vis
and one that is in high demand space, and measuring the Earth’s During his mission Tim Peake
@astro_pi_ir
within the UK’s space industry. magnetic field. will deploy the Astro Pis inside the
Facebook So, back in 2014, Raspberry Pi What would you do with a piece of European Columbus module and
rpf.io/apfb
joined forces with the UK Space equipment like the Sense HAT? Look run each of the student programs
Agency, the European Space for cosmic rays? Make a timelapse of in sequence. Finally, the results
Agency and the UK Space Trade the Earth through a hatch window? will be downloaded back to Earth,
Association to run a competition. Maybe just give Tim games to play? returned to the students that took
This gave school-age students This was the premise of the 2015 part, and made available online for
in the UK the chance to devise Astro Pi student competition which everyone to see.
computer science experiments produced seven winning teams. Want to learn more? Visit
for British ESA Astronaut Their experiments are in the form of astro-pi.org for more information.
START A
CODE CLUB
IN YOUR SCHOOL
Are you a teacher interested in setting up a Code Club in your school?
Find out how simple it is to get started.
t’s easier than you think to for children to follow to create said. “It taps into their problem
I run a Code Club yourself:
you don’t need existing
animations, games, websites, and
much more. Children build up their
solving skills and enables them to
develop critical thinking skills.”
coding skills, just a can-do attitude programming skills as they move “Programming and coding is an
to get stuck in learning alongside through the projects. There are also area of the curriculum that many
your students for an hour a week! challenges to provide opportunities staff can find intimidating. Knowing
If you haven’t yet heard about to apply what they’ve learnt. that the children have some
Code Club, they are a UK-based not- Caroline Harding, a Year 4 experience of the program can help
for-profit organisation offering free teacher who helps to run a Code ease some anxieties and enables
learning materials and support for Club at her school in Croydon, that ‘have a go’ attitude!”
Below teachers, volunteers and parents told us about the benefits the By starting a club at your school
Code Club
allows children running after-school coding clubs club has brought the children. you’ll be joining a huge community
to experiment for children aged 9-11. “Making Code Club available to the of teachers who do the same thing -
and invent,
using different Code Club’s specially designed children in our school has helped around 50% of Code Clubs are run
languages to projects offer structured and tremendously with their confidence by teachers.
create their
own games, fun content for the clubs. The and engagement in coding and If you’re considering getting a
animations projects are step by step guides computing in general,” Caroline Code Club started, we’ve come up
and websites
with a few tips to help you.
Left There is no
cost involved in
starting a Code
Club. It’s free for
schools, and the
kids who attend
FIND
THIS ADVANCING
COMPUTER
& OTHER
RESOURCES:
rpf.io/learn
SCIENCE WITH
RASPBERRY PI
The Raspberry Pi Foundation produces free resources for learners
and educators all over the world. Head of Curriculum Development,
Marc Scott, explains why and how…
ne of the core goals of the Raspberry Pi Teach, Learn and Make
O Foundation is to advance Computer Science
education, and one of the key ways in which
Head on over to raspberrypi.org/resources and you’ll
find three categories of resources from which to
we attempt to achieve this is in the publication of free cherry-pick: Teach, Learn and Make.
educational resources. Our aim is to be the first port Our rapidly growing set of Teach resources are
of call for educational materials, whether you are a designed with educators in mind. There you can find
learner who has just unboxed your first Raspberry Pi complete sets of lesson plans, student worksheets
computer, or an educator teaching Computer Science and resource files ready for you to print off, project,
to eager students of any age and level. or just to direct your students to. Some schemes
require Raspberry Pis, such as the Networking
lessons. Some are cross-platform, such as the Sonic
Pi lessons on making music. Some tackle tricky
concepts in Computer Science, such as the Sorting
Algorithm lessons. There are even some cross-
curricular schemes, such as Sensing Space.
Our Learn and Make resources are designed
to be accessed by learners without necessarily
requiring the support of an educator. They could
also easily be used in lessons and are especially
suitable for after-school or lunchtime clubs. If
you’ve ever wanted to build a device to tell you
how many astronauts are currently in space,
predict the future with a digital Magic 8-Ball, or
learn what it’s like to float around in zero-g, this
FLAPPY ASTRONAUT
This resource is for the more advanced learner. It uses the new Sense
Free as in Beer and Speech HAT hardware along with some Python code to produce a clone of
A key difference between the Raspberry Pi Foundation Flappy Bird, in which the player navigates between pipes by vigorously
resources, and those produced by many other shaking the Raspberry Pi to overcome gravity. It’s a tricky game to
organisations, is that ours are free. That’s free master, but a lot of fun to play. Test it yourself at rpf.io/flappy.
in both senses of the word!
Both time and money are finite, and we recognise
that educators can spare little of either. That’s why Get involved
we’ve created these resources for you to use in any We’re a very small team here at the Raspberry Pi
way you wish, and why you’ll never be charged for Foundation, and as such we rely a huge amount on our
downloading, printing or sharing them. In fact, wonderful community of enthusiasts, tinkerers and
we would encourage you to do all those things. educators. Not only do they use our resources, they
We’re big believers in open source software at the contribute as well, doing anything from correcting a few
Foundation, and our attitude to educational resources typos right up to producing full schemes of work for us
FIND
THIS
& OTHER
RESOURCES:
rpf.io/learn
You’ll
Need MAKE A DIGITAL
MAGIC 8 BALL
> Sense HAT
magpi.cc/
SenseHAT
import random
import time
print(random.choice(replies))
LIVE CODING
&& Digital musician and Cambridge Computer Lab researcher Sam Aaron
You’ll introduces Sonic Pi and the art of live coding
Need he laser beams sliced through the wafts of Live loop
>R
aspberry Pi
running Raspbian
T smoke as the subwoofer pumped bass deep
into the bodies of the crowd. The atmosphere
The key to live coding with Sonic Pi is mastering the
live_loop. Let’s look at one:
>S
onic Pi v2.6+ was rife with a heady mix of synths and dancing.
>S
peakers or However, something wasn’t quite right in this live_loop :beats do
headphones with nightclub. Projected in bright colours above the DJ sample :bd_haus
a 3.5mm jack
booth was futuristic text - moving, dancing, flashing. sleep 0.5
>U
pdate Sonic Pi: This wasn’t fancy visuals; it was merely a projection end
sudo apt-get
of Sonic Pi running on a Raspberry Pi. The occupant of
update && sudo
apt-get install the DJ booth wasn’t spinning discs; she was writing, There are four core ingredients to a live_loop. The
sonic-pi editing, and evaluating code. Live. This is live coding. first is its name. Our live_loop above is called :beats.
This may sound like a far-fetched story from the You’re free to call yours anything you want. Go crazy.
future, but coding music like this is a growing trend Be creative. I often use names that communicate
and is often described as live coding (toplap.org). something about the music they’re making to the
One of the recent directions this approach to music- audience. The second ingredient is the do word, which
making has taken is the Algorave (algorave.com); marks where the live_loop starts. The third is the
these are events where artists code live music for end word, which marks where the live_loop finishes.
people to dance to. However, you don’t need to be in a Finally, there is the body of the live_loop, which
nightclub to live-code; with Sonic Pi v2.6+, you can do describes what the loop is going to repeat – that’s
it anywhere you can take your Raspberry Pi and a pair of the bit between the do and end. In this case, we’re
headphones or some speakers. Once you reach the end repeatedly playing a bass drum sample and waiting
of this article, you’ll be programming your own beats for half a beat. This produces a nice regular bass beat.
Below The new
and modifying them live. Where you go afterwards will Go ahead: copy it into an empty Sonic Pi buffer and hit
Dark theme for
v2.6 is lovely! only be constrained by your imagination. Run. Boom, boom, boom!
Redefining on-the-fly
OK, so what’s so special about the live_loop? So far
it just seems like a glorified ‘loop’! Well, the beauty of
live_loops is that you can redefine them on-the-fly.
This means that while they’re still running, you can
change what they do. This is the secret to live coding
with Sonic Pi. Let’s have a play:
live_loop :choral_drone do
sample :ambi_choir, rate: 0.4
sleep 1
end
If you try running this code, you’ll immediately see Bringing it all together
Sonic Pi complaining that the live_loop did not sleep. We are going to round this tutorial up with a new piece
This is a safety system kicking in! Take a moment to of music which draws from all of the ideas we have
think about what this code is asking the computer to introduced so far. Read this code and see if you can
do. That’s right, it’s asking the computer to play an imagine what it’s doing. Then, copy it into a fresh Sonic
infinite amount of choir samples in zero time. Without Pi buffer, hit Run and hear what it actually sounds like.
the safety system, the poor computer will try to do this Finally, change one of the numbers, or comment and
and crash and burn in the process. So remember- your uncomment things some of the lines out. See if you
live_loops must contain a sleep. can use this as a starting point for a new performance.
Above all, have fun!
Combining sounds
Music is full of things happening at the same time. with_fx :reverb, room: 1 do
Drums at the same time as bass at the same time as live_loop :time do
vocals at the same time as guitars... In computing we synth :prophet, release: 8, note: :e1, cutoff: 90, amp: 3
call this concurrency, and Sonic Pi provides us with an sleep 8
amazingly simple way of playing things at the same end
time. Simply use more than one live_loop! end
TNT RUN!
Can you outrun an explosion?
Test your speed with this marvellous Minecraft mini-game!
INFO CARD
Difficulty
Medium
Type
Programming
Requirements
Raspberry Pi computer One of the many amazing things about Raspberry Pi computers is that Bash the first block
to trigger the chain
Raspbian from they come with their own edition of Minecraft included for free. And reaction along the TNT
raspberrypi.org/downloads even better, you can code it in Python using the Minecraft API! In the
next 30 minutes you will create a game called TNT RUN, in which you
start at one end of a long line of TNT and have to try to make it to the
safe area without the TNT exploding in your face.
The Minecraft API gives us you need to look directly into the
complete control over many invisible bedrock.
elements of the game. This TNT also behaves differently in
includes teleporting players the Pi edition. Whereas in other
around the world and displaying editions you set TNT off with
helpful messages to the screen. flint and steel, a fire charge or a
We are also able to place blocks flaming arrow, in the Pi edition
automatically – not just one at a you simply need to hit it a couple
time, but as a three-dimensional of times with anything. However,
collection of blocks. you can’t just do this with any old
This game will also include a TNT block: first, we need to set its
block which is unique to Pi and block data value to an odd number
Pocket editions: invisible bedrock. (1, 3, 5, 7, or 9). Most blocks have a
We use this block to keep the block data value; by changing this
TNT from falling to the ground value, you will alter the block’s
when lit, and as an invisible path behaviour. For example, when you
leading to the safe area. You may set a nether reactor core’s block
find something strange about data value to 1, it appears in a red
this block when you place it next colour; if you set it to 2 then it will
to a non-invisible block, so try come out as a dark blue colour. We
experimenting: you will find that use these cool-looking blocks to
Language
TNTRUN.py >PYTHON 2.7
How to
play:
# import all the necessary modules pos.z-88,pos.x,pos.y-7,pos.z-88, DOWNLOAD: >T
he start of the
from mcpi.minecraft import Minecraft block.BEDROCK_INVISIBLE.id) github.com/
TNT line will
snake48/TNTRUN
from mcpi import block mc.setBlocks(pos.x+1, appear directly
import time pos.y-1,pos.z-88,pos.x, underneath you.
pos.y-7,pos.z-88,block.BEDROCK_INVISIBLE.id) >T
he TNT won’t
# connect with the Minecraft world mc.setBlocks(pos.x,pos.y,pos.z,pos.x, just light itself;
you need to
mc=Minecraft.create() pos.y-7,pos.z-92,block.BEDROCK_INVISIBLE.id) detonate the first
block of TNT by
# get the player’s position # build the bomb hitting it a couple
of times.
pos=mc.player.getTilePos() mc.setBlocks(pos.x,pos.y,pos.z,pos.x,pos.y,
pos.z-88,block.TNT.id,1) > Once you’ve lit
it (you’ll know
# check if the end of the world will engulf your when it starts
#creation & then move you if you’re too close # build the end podium flashing white),
if pos.z<-40: mc.setBlocks(pos.x-2,pos.y,pos.z-93, turn around
and then run for
mc.postToChat( pos.x+2,pos.y,pos.z-97,block.GLOWING_OBSIDIAN.id) your life!
'teleporting to safer distance in progress!') mc.setBlocks(pos.x-1,pos.y+1,pos.z-94,pos.x+1,
>T
ry to get to the
mc.player.setPos(pos.x,pos.y,-40) pos.y+1,pos.z-96,block.NETHER_REACTOR_CORE.id,1) teleporter, as it
pos=mc.player.getTilePos() mc.setBlock(pos.x,pos.y+2,pos.z-95, will give you an
block.REDSTONE_ORE.id) 18-block boost.
mark the position of the teleporter point. When you run the code,
and as a part of the end podium. make sure Minecraft is running,
The teleporter function in the code otherwise your code will give you a
is designed so that if you manage connection error.
This is the safe area
to get to a certain point along the Once you have finished the you need to run to.
If you make it there,
line of TNT, it gives you a boost project, you can customise your you’ve won
and teleports you forward. own version of the TNT Run game
When you create your Minecraft by adding changes like making
world, fly around it and find a cool the row of TNT longer, or creating
location to create your TNT course a fancier safe area. Also, when
(i.e. not when you are near a cliff you’re connected to a network
or the end of the world). Your with other Raspberry Pis, you can
code takes the player’s position join someone else’s world, create
and constructs the TNT course, two lines of TNT and race to the
using this location as the starting safe areas simultaneously! The dark blue nether reactor core marks the location of the teleporter
raspberrypi.org/resources
raspberrypi.org/education Educator’s Edition 19
SUBSCRIBE TODAY
& SAVE UP TO 40% ESSENTIALS
How to subscribe:
Call on 01202 586848 and
ask us about our educator rates
1 [ Chapter One ]