In this video, Mark Niemann-Ross explains four steps necessary to configure a Raspberry Pi GPIO pin for input. These steps include 1) Choose the physical pin 2) Create the physical circuit 3) Identify the software address and 4) Write appropriate software. Following this checklist will demystify the process of connecting the Raspberry Pi to an outside circuit.
- [Voiceover] One of the confusing parts of working with the Raspberry Pi GPIO is that some pins can be either input or output, depending on how they're configured. Setting up the Raspberry Pi to read an input requires several steps. As I discussed earlier, the first step in setting up the Raspberry Pi to read an input is to choose an appropriate pin. Not all pins can be read. Some only supply power or ground. Refer to the chart included in the example files of this course to choose a pin.
Next, to build an appropriate circuit, I've already built a simple circuit and in an upcoming video, I'll explore some ways to build a more robust circuit that will protect the Raspberry Pi from potential mistakes. With a working circuit, the next step is to correctly identify the software address for the hardware pin. Again, use the chart enclosed in the example files to determine which addressing scheme and pin address to use. Finally, write software that accomplishes the objectives in the most efficient way possible.
There are examples for several different languages at the Rpi GPIO Code Sample page on elinux.org. In this course, I'll show exactly how to setup input pins with Scratch and Python. In both examples, we'll follow this basic set of steps.
- Locating the GPIO
- Programming with Python and Scratch
- Working with breadboards, jumpers, and components
- Building a simple GPIO project
- Identifying GPIO pins
- Using the WiringPi and RPi.GPIO libraries
- Accepting input
- Controlling output
- Using specialty pins: UART and I2C