Raspberry Pi Controlling LED's Via GPIOFollow article
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)
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.
Step 3 introduces the concept of opening a file and editing and reusing Python code. The concept of adding comments to code to make it more “human understandable”, and the concept of assigning values to variables are also introduced.
Note- These exercises were created 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.
Please see attached files for exercises and Raspberry Pi Setup guides