LED piscando em Beaglebone Preto

LED flashing on Beaglebone Black

Blinking LED on Beaglebone Blank

Let's start by explaining the Beaglebone Black's various peripheral interfaces. I will start with a simple external LED blinking with BBB to better understand the GPIO pin configuration and usage. I chose the python scripting language for programming, but you can write it in any other language as well. I used the adafruit python BBB library to make the application.

Required tools :

  • Black Beaglebone
  • Led
  • 330Ω resistor
  • Test board
  • Female to female connectors

Software environment configuration

Install the latest version of python on BBB as explained in the tutorial How to make the first python program with Beaglebone Black. Install the adafruit python-GPIO library called adafruit_BBIO.

Working

It is a simple black Beaglebone learning tutorial. Here I connected two LEDs with a black Beaglebone GPIO pin. When the script is running, both LEDs turn on and off for one second. After running it five times, the pin status and configuration become clear.

Description

Let's first prepare the circuit connection. Take a breadboard and supply VCC and ground from BBB to the breadboard line. Connect 3.3V power to pin number 3 of the P9 head and ground to pin number 2 of the P8 head. Connect the negative and positive terminals of both LEDs to ground and 330 OHM resistor respectively. Connect the other end of both resistors to pin numbers 8 and 9 of the P8 header. Supply power to the black Beaglebone by connecting it to the PC via a USB cable. Now your circuit is prepared.

Open the command terminal and access Beaglebone black through SSH as explained in getting started with Beaglebone black. Create a new file using play command with .py extension. Open the file with any text editor (i.e. nano, vim etc.) and write code in python language.

GPIO pin configuration

Import the GPIO library from the adafruit Beaglebone black library by calling the following line in the program:

import Adafruit_BBIO.GPIO as GPIO

You can set PIN number with underline followed by your number. (i.e. P8_8). Give it an appropriate name.

i.e. LED1 = “P8_8”

Here I have assigned the name LED1 to pin number 8th ah header P8.

Next, configure the pin as input or output according to the following function:

GPIO.setup (pin number, output/input)

For example, I declared LED1 (pin number 8 oh header P8) as output by the following line:

GPIO configuration (LED1,GPIO.OUT)

If you want to declare it as input, you can declare it as follows:

GPIO Configuration (LED1,GPIO.IN)

Note: here I declared LED as output. (led is output device)

You can make the pin high and low by following the function:

GPIO.out ( High or low PIN number )

For example, I made led1 (pin number 8 oh header P8) as High and Low following the line:

HIGH: GPIO.output (LED1, GPIO.HIGH)

LOW: GPIO output (LED1, GPIO.LOW)

Back to the blog

Leave a comment

Comments need to be approved before publication.