<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Quy Nguyen</title>
    <description>The latest articles on DEV Community by Quy Nguyen (@govapemaker).</description>
    <link>https://dev.to/govapemaker</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2640006%2Fd39d0060-6b84-4f62-874f-3d03c1653170.png</url>
      <title>DEV Community: Quy Nguyen</title>
      <link>https://dev.to/govapemaker</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/govapemaker"/>
    <language>en</language>
    <item>
      <title>Test GPIO pins on BeagleBone Black by toggling high to low</title>
      <dc:creator>Quy Nguyen</dc:creator>
      <pubDate>Wed, 01 Jan 2025 13:09:32 +0000</pubDate>
      <link>https://dev.to/govapemaker/test-gpio-pins-on-beaglebone-black-by-toggling-high-to-low-35g4</link>
      <guid>https://dev.to/govapemaker/test-gpio-pins-on-beaglebone-black-by-toggling-high-to-low-35g4</guid>
      <description>&lt;p&gt;Tutorial: Testing GPIO Pins on BeagleBone Black Using Bash&lt;br&gt;
This tutorial explains how to write and execute a Bash script to test GPIO pins on the BeagleBone Black. The GPIO (General-Purpose Input/Output) pins are versatile and can be controlled programmatically. Here, we'll guide you step-by-step on using a simple script to toggle a GPIO pin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbnqtq2v922b558mqablq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbnqtq2v922b558mqablq.jpg" alt="Image description" width="722" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prerequisites
Before starting, ensure the following:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You have access to a BeagleBone Black board.&lt;br&gt;
The board runs a Linux-based operating system.&lt;br&gt;
You have root access (some operations require elevated privileges).&lt;br&gt;
The GPIO pin numbering and mappings for your board are known.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding GPIO Pins
GPIO pins are accessible through the Linux filesystem under /sys/class/gpio. Each GPIO pin is represented by a number that you can use to control its state. For example:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;P8 Pin 12 corresponds to GPIO1_12, which is 44 in GPIO numbering.&lt;br&gt;
The calculation for GPIO number is:&lt;br&gt;
GPIO Pin = (Bank Number × 32) + Pin Number.&lt;br&gt;
Refer to the BeagleBone Black GPIO Pinout for details.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Script Overview
The script performs the following:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Exports a GPIO pin for user control.&lt;br&gt;
Sets the pin direction to output.&lt;br&gt;
Toggles the pin state (HIGH/LOW) three times with 1-second intervals.&lt;br&gt;
Unexports the pin after testing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Bash Script
Here’s the script:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

# Define the GPIO pin to test
# Examples of GPIO numbers:
# P8 Pin 11 -&amp;gt; GPIO1_13 = 45
# P8 Pin 12 -&amp;gt; GPIO1_12 = 44
# P8 Pin 14 -&amp;gt; GPIO0_26 = 26
# P8 Pin 16 -&amp;gt; GPIO1_14 = 46

TESTPIN=44  # Replace with your target GPIO pin number

# Export the GPIO pin to make it available
echo "$TESTPIN" &amp;gt; /sys/class/gpio/export

# Set the direction of the pin as output
echo "out" &amp;gt; /sys/class/gpio/gpio$TESTPIN/direction

# Toggle the pin value HIGH and LOW three times
for i in {1..3}; do
  echo "Setting gpio$TESTPIN HIGH"
  echo "1" &amp;gt; /sys/class/gpio/gpio$TESTPIN/value
  sleep 1  # Wait for 1 second

  echo "Setting gpio$TESTPIN LOW"
  echo "0" &amp;gt; /sys/class/gpio/gpio$TESTPIN/value
  sleep 1  # Wait for 1 second
done

# Unexport the GPIO pin after testing
echo "$TESTPIN" &amp;gt; /sys/class/gpio/unexport
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want more information, please visit &lt;a href="https://blog.govapemaker.com/" rel="noopener noreferrer"&gt;GOVAPEMAKER&lt;/a&gt;&lt;/p&gt;

</description>
      <category>govapemaker</category>
      <category>bash</category>
      <category>linux</category>
      <category>beaglebone</category>
    </item>
  </channel>
</rss>
