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


Gefällt dir, was du gelesen hast? Warum zeigst du nicht deine Wertschätzung, indem du etwas Liebe gibst?

Von einem schnellen Antippen bis zum Zerschlagen des Liebesknopfs und zeigen Sie, wie sehr Ihnen dieses Projekt gefallen hat.


Unsere Website verwendet zu analytischen Zwecken und zur Personalisierung Ihrer Werbung Cookies und ähnliche Technologien, um Ihnen einen besseren Service zu liefern, während Sie Produkte suchen oder eine Bestellung aufgeben. Sie können Ihre Cookieeinstellungen ändern, indem Sie unsere Cookierichtlinie lesen. Andernfalls nehmen wir an, dass Sie unserer Verwendung von Cookies ZUSTIMMEN.


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

Browse the US site