All posts by admin

Beaglebone Black LESSON 4: Digital Write to the GPIO Pins from Python

In this lesson we show you how to do digital writes to the GPIO pins from python. If you do not already have a Beaglebone Black Rev C, you can order one HERE.

In order to do this lesson, we need to go back and review the pinout diagram from LESSON 1.

Beaglebone Black Pinout
Default Pin Configuration for the Beaglebone Black Rev. C.

In Python, we reference pins by first specifying which header we want (P8 or P9) and then which physical Pin. For Example, to specify pin 12 on the left header, we would refer to it as “P9_12”. For digital output, we should use one of the pins above that is shaded green.

To talk to the GPIO pins in Python, we must first import a library. The latest versions of the Beaglebone Black Rev C. are shipping with the library already installed. If you have an earlier version, you need to update to the latest operating system. You can visit the beagleboard.org web site to download the latest operating system. If you get an error when you try and load the library, you know that either you have typed the command in wrong, or you need to update your operating system. In python to import the library you need to include the line:

Once you have imported the library, you then need to setup your pin as an output pin:

Now if you want to set that pin high you can use the command:

To set the pin low you can use the command:

After you are done working with the pin, you should “cleanup” to free the pin up:

These are all the commands you need in order to set the pin “HIGH” or “LOW”. Remember that in the High state, the Beaglebone Black outputs 3.3 Volts.

We can bring things together to make a simple program that will turn the pin on and off in three second intervals. Try and play around yourself with this code. Then try different GPIO pins.

 

Beaglebone Black LESSON 3: Running Python on Your Beaglebone

In this series of lessons, we will be controlling the GPIO pins from Python. If you do not already have a Beaglebone Black Rev. C, you can pick one up HERE.

In this lesson we show you how to write and run a simple Python program. Be sure to go through LESSON 2, which shows you how to boot and remotely connect to the Beaglebone. You will need to know how to do that for this lesson.

Beaglebone Black LESSON 2: Getting Started

In this lesson we show you how to boot up your Beaglebone Black, and how to connect via the Putty SSH terminal client, and how to remotely run the graphical desktop on your PC. If you do not already have your Beaglebone Black, you can pick up one HERE.

The Beaglebone black has only one USB connection, so I find the easiest way to work with it is to just connect by a remote desktop, instead of trying to connect screen, keyboard, and mouse directly to the Beaglebone. This lesson will get you started so you can get connected and talking to your Beaglebone.

Beaglebone Black LESSON 1: Understanding Beaglebone Black Pinout

This is the first in a series of lessons on the Beaglebone Black. Hopefully you have been with us through our earlier series of lessons on the Arduino, Python, and the Raspberry Pi. If you have been through those lessons learning the Beaglebone will be a snap.

If you are going to follow along with us in these lessons, you can go ahead and order your Beaglebone HERE.

To get started, we need to first of all get our mind around all the different pins. I have put together the diagram below for the default pin assignments for the Beaglebone black.

Beaglebone Black Pinout
Default Pin Configuration for the Beaglebone Black Rev. C.

You can see that the Beaglebone has a large number of pins. There are two headers. Make sure you orient your Beaglebone n the same direction as mine in the picture, with the five volt plug on the top. In this orientation, the pin header on the left is referred to as “P9” and the pin header on the right is referred to as “P8”.  The legend in the diagram above shows the funtions, or the possible functions of the various pins. First, we have shaded in red the various 5V, 3.3V, 1.8V and ground pins. Note that VDD_ADC is a 1.8 Volt supply and is used to provide a reference for Analog Read functions. The general purpose GPIO pins have been shaded in green. Note some of these green pins can also be used for UART serial communication. If you want to simmulate analog output, between 0 and 3.3 volts, you can use the PWM pins shaded in purple. The light blue pins can be used as analog in. Please note that the Analog In reads between 0 and 1.8 volts. You should not allow these pins to see higher voltages that 1.8 volts. When using these pins, use pins 32 and 34 as your voltage reference and ground, as pin 32 outputs a handy 1.8 volts.  The pins shaded in light orange can be used for I2C.  The dark orange pins are primarily used for LCD screen applications.

Comparing the Arduino, Raspberry Pi Model 2, and Beaglebone Black

In this video we do a head to head comparison of the Arduino, Raspberry Pi Model 2, and the Beaglebone black. We compare the pros and cons of each platform and discuss how to decide which platform to learn on and which is best for different types of projects.

You can pick up the gear discussed in this video below:

Arduino: This is a great place to start, and the device is very affordable.

Sparkfun Inventor Kit: Everything you need to learn microcontroller programming and circuits. This is the kit we use in our Arduino Lessons, and even includes the Arduino.

Raspberry Pi Kit: This kit has everything you need to follow along on our Raspberry Pi Lessons.

Raspberry Pi: If you already have the cords and cables, you can buy just the Raspberry Pi.

Beaglebone Black: We are not working on a series of lessons showing you how to use the Beaglebone Black. Now would be a good time to go ahead and order your Beagle.

I hope you enjoyed this video lesson, and hope you will jump in and take our lessons on using the Arduino, Raspberry Pi, and the Beaglebone Black