Tag Archives: GPIO

Understanding Raspberry Pi 4 GPIO Pinouts

Diagram of physical and BCM Pins on Raspberry Pi

This shows the pinout for the Raspberry Pi 4. It shows both the BOARD numbering scheme, and the BCM numbering scheme. You define which numbering scheme you want to use in your python program. You must start by importing the GPIO Library:

import RPi.GPIO as GPIO

Then, if you use setmode to define which numbering scheme you want:

GPIO.setmode(GPIO.BOARD)

will give you the Physical Pin numbering scheme.

If you use:

GPIO.setmode(GPIO.BCM)

You will be using the BCM Numbering Scheme. I prefer the BOARD Scheme as it is  much easier to keep track of. Hope this helps.

Beaglebone LESSON 8: Read Button State from Python


In this tutorial we will see how to read digital values from the GPIO pins. We will be doing digital reads, which means we will be limited to “HIGH” or “LOW” readings. This is a 3.3 volt system, so we need to make sure that the “HIGH” applied signal is 3.3 volts.

Our pinout from LESSON 1 shows which pins are suitable for digital reads.

Default Pin Configuration for the Beaglebone Black Rev. C.

It is the green GPIO pins which we can use for digital reads. In this lesson we will demonstrate the digital read technique using a simple two button circuit. In order to complete this lesson, you should go ahead and build this circuit.

Example of Simple Beaglebone Black Button Circuit

Notice we are using Pin 1 on Header P9 as the ground and Pins 11 and 13 on header P9 s the input pins. Also note the pulldown resistors are 1000 Ohm. It is important to use at least this much resistance. If you do not have 1,000 Ohm resistors, using something larger NOT something smaller.

Once you have the circuit set up we are ready to begin programming.

First up, you need to import the GPIO library. If you have the latest version of Debian Wheezy, you should have the library on your system. If you do not have it you will need to update and upgrade your operating system. To load the library, you will use the python command:

We now need to configure out pins P9_11 and P9_13 as inputs. We do this with the command:

Now to read the state of the buttons, we would use the commands:

state1 will be True if the top button is pushed, and False if it is not being pushed. Similarly, state2 will be True when the button is being pushed, and False when it is not being pushed.

We can bring these concepts together to make the following program. Play around with the program and see what all you can make it do.

 

Beaglebone Black LESSON 5: Blinking LEDs from GPIO Pins

This lesson shows a simple example of how to blink two LEDs from the GPIO pins on the Beaglebone Black. To get going, you will need to hook up the following circuit. (If you have not ordered your Beaglebone Black, you can get one HERE.)

Circuit for Blinking LEDs from Beaglebone Black

Note that the Top LED is connected to Pin “P9_12” and the bottom LED is connected to Pin “P9_11”. We are using 330 ohm current limiting resistors.

The video lesson takes you through several examples of how to blink the LED. Watch the video, and do the examples. Then play around on your own and see what you can make the LEDs do.