In this section I hope to include snippets of code, ideas from yourselves and some projects that our students have worked on. I will also link to things I find around the web that I think you (teachers & students) will use to help you better understand how to programme with the raspberry Pi.
The introduction of computer science into the curriculum is a great way to engage our students in developing independent thinking and problem solving skills which are transferable to other areas of life other than computing.
The raspberry pi is a great way to learn programming and some electronics. With the ability to attach hardware that it can communicate with, this provides a great way to help foster creativity in kids to inspire their own ideas.
Without further delay, let’s start!
Basics in Python
Before you start, you must have some basic knowledge in Python. Honestly you don’t need much experience but how to write basic instructions in Python with loops and conditions in simple form is enough. Head over to our webpage on Python basics or try some of these websites for a great way to learn the basics:
Code Academy (great interactive Python courses)
Data Camp (Great interactive Python learning site)
LearnPython.org (Now also interactive thanks to DataCamp!)
The GPIO pins
The RPi comes in many different versions now. While the earlier models had 26 pins, the newer models now have 40 pins that enable users to connect external hardware. This opens many possibilities for creativity. Have a look at this for example.
GPIO stands for General Purpose Input Output. The pins either receive or send a signal that is either high or low. Since computers really only understand 1 or 0, it regards high signals as 1 and low signals as 0. Quoting from The University of Cambridge website:
a GPIO pin can be set high (taking the value 1) by connecting it to a voltage supply, or set low (taking the value 0) by connecting it to ground. The Raspberry Pi can set the pin to take either value and treat it as an output, or it can detect the value of the pin and treat it as an input.
Of the 26/40 pins there are two 3.3v, two 5v and five ground pins.There are also quite a few GPIO pins which is what will detect or send out the high/low signal to external hardware. The other pins will probably not be used in our projects but a great interactive explanation of them has been shared by Pinout.xyz which is quite useful.
|Early 26 pin RPis||40 Pin RPis|
Taken from hifiduino.files.wordpress.com
Notice how the numbers of the pins and GPIO number are different.
Scroll down below to find out how to attach various hardware using the GPIO ports. (Click on bulleted points to expand)
Code Snippets for Devices You Can Connect
A big shout needs to go out to raspberrypi-spy.co.uk and raspberrypi.org. Some of the guides here are taken directly from them and some guides are linked to their great resources. My intention here is to simply put together a simple list of devices students can find in one place.
Raspberry Pi Devices
With LEDs its is important you use the correct resistor for the correct LED. Refer to wherever you have purchased the LED to be sure.
Adding PS3/Ps4 Controller
Adding Bluetooth Adapter
Easy Project Ideas that Students can follow
Here you can find project examples from around the web that students can use to build or to inspire them into making similar projects with the help of the examples here. All credit goes to the original authors.
(Library coming here soon)
Check out The LearnICT.it Github Repository for more coding examples and ideas.
Get a copy of all the scripts we use in our raspberry pi club by creating a folder and typing the following code into terminal using your pi:
git clone git://github.com/learnICT/RPi-club.git
From time to time the scripts are updated. To get the latest update, open the scripts folder you created with terminal again and type in: