Resources – Computing Club Sessions – Raspberry Pi 2 – Python

Overview

This is an opportunity to look at another language (Python), another IDE (IDLE) and have another go at Scissors, Paper, Stone.

Hardware

This is going to use the GPIO pins (the two rows of 13 pins – 26 in total) on the Pi. We'll connect them to the 3 boxes we used in the PIC session via a breadboard.

Raspberry Pi

Start by connecting all the usual bits to the Pi – but DON'T plug the power supply in or switch it on yet!

Resources - Computing Club Sessions - Raspberry Pi 2 - Python

The breadboard I've used is an SYB-120 700 point breadboard. These are cheap and readily available on eBay. For anyone who's never used one, the idea is that there are lots of connection points and inside they are joined together in groups. If you hold it vertically, on this board there are 60 rows, each with 10 connection points (and also one column of 50 down each side, but we won't be using those). Each row has 5 connection points on the left, all joined inside – and 5 on the right, all joined – with a gap in the middle.

We'll use jumper wires to connect the breadboard to the GPIO pins on the Pi, so we'll need plenty of male to female jumper wires (readily available on eBay). We'll also need a few male to male jumper wires for connections between points on the breadboard.

Lastly we'll need some 470 ohm resistors.

See links on the first Raspberry Pi session page for links to relevant sources.

This image shows the pins on the Pi. A word of warning here – the Pi mostly runs on 3.3V – but the 5V0 GPIO pin (pin 2 – see below) exposes the raw 5V USB supply voltage. That 5V can be enough to kill the Pi permanently as there is no general voltage protection on the GPIO pins, so be VERY careful not to connect ANYTHING to that 5V pin. You might even want to cut off a female connector from a jumper wire and put it on the pin beforehand to stop anyone putting anything else on it.

Raspberry Pi GPIO pins

The wiring diagram (see link below) shows how to connect everything up and pin numbering on the Pi.

Start with the connections from 3 boxes to the breadboard down the left hand side (don't worry about the 3 VSS white wires for the moment).

Then plug in the 7 resistors (470 ohm) – the black rectangular blobs on the diagram. These are pull-up resistors on the switch inputs – the PIC had pull-up resistors built into the chip, so we didn't need these. The Pi doesn't, so we need extra external components. The idea is that the input pin is weakly connected to VSS (0V) via the resistor when the button is not pressed – but connected straight to VDD (3.3V in this case) when it is pressed. See the Circuit Components handout.

Breadboard Closeup

Now connect the Pi pins to the breadboard (don't worry about connections from pins 1 and 6 yet) with male to female jumper wires. It's a good idea to keep things colour coded – use the same colour wires here as for the corresponding wires from the boxes. Do make sure the resistor wires don't touch each other or anything else . . .

Resources - Computing Club Sessions - Raspberry Pi 2 - Python SchematicNow a couple of male to male jumper wires for the links shown to tie all the right hand ends of the resistors together.

Now plug the 3 white VSS wires from the boxes in.

And finally jumpers from the Pi pins 1 and 6 to the VDD and VSS connection points.

For the curious, the S and D in VSS and VDD stand for Source and Drain – with VSS being 0V and VDD being 3.3V Electrons are negatively charged and flow from negative to positive – i.e. 0V to 3.3V – so VSS is a source of elctrons and VDD is where they drain away.

 

For more detail: Resources – Computing Club Sessions – Raspberry Pi 2 – Python


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top