Here’s a neat trick to impress your friends at parties. Control your LEDs via the GPIO pins with nothing more than your trusty Raspberry Pi. It’s pretty easy to do if you’re in the know. So we thought we’d let you in on the secret. And help you to see the light.

The main thing is to figure out how to program the GPIO pins on the Raspberry Pi as digital outputs. It’s these pins that will control your LEDs plus a seven segment LED display.

All set? Let’s go…

Getting Started

Your Pi has a few General Purpose Input Output (GPIO) pins which can be programmed as DIGITAL inputs or outputs. Digital inputs and outputs can only ever be “ON” (digital state “1”) or “OFF” (digital state “0”).

You’ll find the GPIO pins tucked away at one corner of your Pi:

You’ll have 40 pins in all, and they’re used for a ton of stuff. You don’t have to know what they all do, but you do have to note how they’re numbered.

Learning objectives

Learning Objectives

As ever, we’ve split the exercises into 3 steps of increasing complexity.

Step 1

We start off by checking out the integrated development environment as well as basic Python by entering commands at the Python prompt. We’ll also look at “user privileges” under Linux (really, it’s beyond the scope of this exercise, but what the heck).

Step 2

On to step 2… and here we’ll show you how to create a file containing a set of Python commands, saving the file as a “computer program” and then “running” it. On the way we’ll explore compiler warning and error messages – and just how useful they really are.

Step 3

Finally, we’ll see how to open and edit a file, plus how to re-use Python code. Here we’ll also look at adding comments to code to make it more user friendly, and we’ll finish by showing you how to assign values to variables.

We created these exercises using a Raspberry Pi Model B with a 26 Way GPIO Pin header.  Newer models have a 40 Way GPIO header, but the first 26 pins ae the same.

Now check out these exercises and our Raspberry Pi Setup guides. And with a little help from us, you’ll soon see the light.


Project Bill of Materials

LED Exercises – Student Workbook

LED Exercises – Teachers Notes

Raspberry Pi Set Up Guide – Students

Raspberry Pi Set Up Guide – Teachers


Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.


Onze website maakt gebruik van cookies en vergelijkbare technologieën om u een betere service te bieden bij het zoeken naar of plaatsen van een bestelling, voor analytische doeleinden en om onze advertenties te personaliseren. U kunt aan de hand van ons cookiebeleid uw cookie-instellingen wijzigen. Indien u geen wijzigingen aanbrengt, nemen we aan dat u akkoord gaat met ons gebruik van cookies.


Please select an option to see content specific to your location and shop online.

Browse the US site