RPI: Use GPIO pins and a program to determine TTL gates

Lab Outline

  • Download WiringPi libraries
  • Understand the pin layout for the RPI
  • Understand why you must use a voltage converter in this lab, and how to use it
  • Create a program to determine the type of TTL gate being tested

Use GPIO pins and a program to determine TTL gates


Wiring Pi Libraries

If you have not downloaded the WiringPi libraries, you must do so as you cannot write a program to work with the GPIO pins otherwise. Instructions are below:

If you have Internet connection follow these steps.

Connect to your Pi and, in the terminal, type:

sudo aptitude install git-core

Allow the installation of git, and once it is installed, type:

git clone git://git.drogon.net/wiringPi
cd wiringPi

If you do not have Internet connection, ask your PSO instructor for a flash drive containg the wiringPi libraries and connect it to you Pi. Or you can just as easily go to the url: https://git.drogon.net/?p=wiringPi;a=summary and select the “snapshot” of the top most version. Unizip the download, put it on a USB stick. Then type the following:

sudo mkdir /mnt/usb
sudo mount /dev/sda1 /mnt/usb
cp -r /mnt/usb/wiringPi .
cd wiringPi

The build script included in the wiringPi package will automatically install wiringPi for you.

You can make sure the installation worked correctly by typing:

gpio -v
gpio readall

GPIO Pin layout for RPI

Important: The most essential thing you must remember first before anything is that your RPI cannot handle voltage above 3.3 volts. You have previously been using 5 volts on your breadboard. Thus the necessity for a voltage converter which will be discussed in the next section. Simply stated, your RPI will output 3.3 volts on any GPIO output pin, your TTL gates require 5 volts(thus a conversion is needed) and then going back into your RPI will require the 5 volts to be converted back to 3.3 volts.

Use GPIO pins and a program to determine TTL gates

The information below explains how the GPIO pins work and how there numbering works, you have to read it a few times to get it:

Dealing with the pins on the Pi can be somewhat tricky, as there are three different pin numbering systems to keep track of on the Pi. They are:

  • The Pi’s internal pin numbering,
  • The GPIO pin labels, and
  • wiringPi’s internal pin numbering.

In short, when programming using wiringPi, use the wiringPi pin number associated with a particular Raspberry Pi pin to control it – i.e. setting pin 0 to high in wiringPi sends 3.3V to pin 11 on the Pi.

Provided below is a table3) that contains all of the relevant pin numbers for each pin.

wiringPi pinGPIO pinNamePi pin (bot row)Pi pin (top row)NameGPIO pinwiringPi pin
74GPIO 778TxD1415
017GPIO 01112GPIO 1181
227GPIO 21314Gnd
322GPIO 31516GPIO 4234
3.3V1718GPIO 5245
139MISO2122GPIO 6256


For more detail: RPI: Use GPIO pins and a program to determine TTL gates

© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top