Raspberry Pi Controlling LED’s Via GPIO

The aim of this exercise is to instruct students how to program the GPIO pins on the Raspberry Pi as digital outputs. The GPIO pins will be used to control some LEDs and a seven segment LED display.

The Raspberry Pi has a number of 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”). In this exercise, you will program the Raspberry Pi’s GPIO pins to control some LEDs.

The GPIO pins are located at one corner of the Raspberry Pi, as shown below. There are 26 pins in all, and they are used for a variety of different things. It isn’t important to remember what all the pins do, but it is important to note how they are numbered.

These exercises include a set of Student exercises with additional Teachers notes (see attached files)


Learning Objectives

The exercise is split in to three “Steps” of increasing complexity

Step 1 introduces the student to the IDLE integrated development environment and to the Python programming language by asking them to enter commands directly at the Python prompt. It was also necessary to introduce the concept of “user privileges” under the Linux operating system, although this is really beyond the scope of the exercise.

Step 2 introduces the concept of creating a file containing a series of Python commands, saving this file as a “computer program”, and “running” the program. The concept of compiler warning and error messages, and the usefulness of such messages, is also introduced.

Read More: Raspberry Pi Controlling LED’s Via GPIO


About The Author

Scroll to Top
Read previous post:
Iterated-map circuit creates chaos
Maximize the Energy from Long-Life Batteries

Battery lifetime is a key consideration for the development of the wireless sensor nodes that will populate the Industrial Internet...