DesignSpark Electrical Logolinkedin
Menu Search
Ask a Question

10 Aug 2016, 16:08

Raspberry Pi GPIO Digital I/O Exercises

The aim of this exercise is to show students how to program the Raspberry Pi to measure temperature using a digital “1-wire” sensor connected directly to one of its GPIO pins, how the measured temperature may be used to control a digital output, and how the Raspberry Pi may be used in conjunction with a LED driver chip to display the measured temperature on a multiple digit LED display.

Learning Objectives 

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

Step 1 introduces the student to 1-wire digital sensor technology and demonstrates how such digital sensors may be easily interfaced with the GPIO port on the Raspberry Pi.

Step 2 introduces the student to the IDLE integrated development environment and to the Python programming language, and 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 an operating system kernel is introduced and it is shown how modules may be loaded into the kernel to provide support for hardware interfaces. In Python, some basic data manipulation and formatting is demonstrated, and the “while” loop and “if…else” statement are introduced.

Step 3 introduces the student to the concept of serial and parallel data interfaces, and the Raspberry Pi is configured to use the SPI protocol. Students will be introduced to the “apt-get” command to download, install and update software packages from the Debian repository and will also download Python code from GitHub. Basic data transfer between the Raspberry Pi and peripheral hardware is demonstrated by sending data to the LED driver chip. This introduces the concept of using hexadecimal notation to represent of binary data.

In Python, the “try and “except” statements are introduced and the concept of reusing and adapting code is demonstrated by asking the student to load and edit the code from the previous step.

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

Geek, Blogger, Gadget Junkie, Crisp Junkie, Technology Evangelist. ***If you meet me, ask me for the Pete and Greet Badge code.*** DesignSpark Team twitter - @petenwood

10 Aug 2016, 16:08


June 25, 2018 09:39

Nice article. Needs to be bought up to data 26 Pin GPIO is passè.

0 Votes