A tag already exists with the provided branch name. Beaglebone Black to the GPIO control over Python Flask Webserver HTML Ask Question Asked 7 years ago Modified 4 years, 10 months ago Viewed 995 times 0 Web server can not control the GPIO I wrote. You will be redirected back to this guide once you sign in, and can then subscribe to this guide. Are you sure you want to create this branch? A network connection is required to allow the device to connect to balenaCloud. There are 2 x 46 pins available (well, not all of them are, but we'll get to that later) to use. Connect and share knowledge within a single location that is structured and easy to search. You can access the channels by either referencing the pin "key" or the name. yet but I hope to try it once I have no other options outside of pure Linux or Linux-languages, e.g. In this In this article by Alexander Hiam, author of the book Learning BeagleBone Python Programming, we will go through the initial steps to get your BeagleBone Black set up. Interpreting non-statistically significant results: Do we have "no evidence" or "insufficient evidence" to reject the null? a while back. This is what you should be seeing. Ensure you are working from the root of the extracted project directory. . To create your first fleet, log into your balenaCloud dashboard and click the Create fleet button. The project can be modified and pushed again using the same method as above, but since we are using a development version of the OS, we can enable Local mode and push directly to the device for a faster development cycle. A 4GB or larger SD card. Powered by Discourse, best viewed with JavaScript enabled, What are some Good Python GPIO libraries for BBB, https://github.com/vsergeev/python-periphery, https://circuitpython.org/blinka/beaglebone_black/, https://beagleboard.org/p/projects/tags/python, https://elinux.org/EBC_Exercise_33_pygame, https://github.com/derekmolloy/exploringBB. It waits for the end of the ADC sequence by waiting for /dev/uio5 event. Activate local mode on the device via the dashboard. . Please sign in to subscribe to this guide. Keeping LED constantly on with BeagleBone black and python, How a top-ranked engineering school reimagined CS curriculum (Ep. I found this lib. For example, pin 7 on header P8 is P8_7. It's fairly simple to use. Remove and re-connect power to the BeagleBone Black to boot the device. hb```` B,@CZ\O3t800u``l5vn% @.' It is recommended to use an official BeagleBoard.org Debian image, Adafruit_BBIO supports Linux kernels 3.8 through 4.19. Copy Code. Extracting arguments from a list of function calls, Simple deform modifier is deforming my object, Image of minimal degree representation of quasisimple group unique up to conjugacy, Ubuntu won't accept my choice of password. When the rebuild is complete, take a look at the public device URL again to see your changes. The languages i used are Python, Flask and HTML. Use the tables to identify power and ground, then pick a GPIO pin that doesn't seem to have too many other uses. library is fairly simple. 1. Note: Follow the instructions on BeagleBoard.org to get connected to the Internet. {"appState":{"pageLoadApiCallsStatus":true},"articleState":{"article":{"headers":{"creationTime":"2016-03-26T08:06:31+00:00","modifiedTime":"2016-03-26T08:06:31+00:00","timestamp":"2022-09-14T17:52:40+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Computers","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33513"},"slug":"computers","categoryId":33513},{"name":"Hardware","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33516"},"slug":"hardware","categoryId":33516},{"name":"BeagleBone","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33518"},"slug":"beaglebone","categoryId":33518}],"title":"How to Control BeagleBone's GPIOs","strippedTitle":"how to control beaglebone's gpios","slug":"how-to-control-beaglebones-gpios","canonicalUrl":"","seo":{"metaDescription":"Following is a handy reference that you can use to control and access your BeagleBones general purpose input/output (GPIOs) with the file system, BoneScript, a","noIndex":0,"noFollow":0},"content":"

Following is a handy reference that you can use to control and access your BeagleBones general purpose input/output (GPIOs) with the file system, BoneScript, and Python.

\n

Controlling the GPIO with the file system

\n

You can use the following commands to control the GPIO with the file system.

\n
    \n
  • Exporting a pin:

    \n
    echo 40 > /sys/class/gpio/export
    \n
  • \n
  • Setting a pin OUTPUT:

    \n
    echo out > /sys/class/gpio/gpio40/direction
    \n
  • \n
  • Writing a pin HIGH:

    \n
    echo 1 > /sys/class/gpio/gpio40/value
    \n
  • \n
  • Writing a pin LOW:

    \n
    echo 0 > /sys/class/gpio/gpio40/value
    \n
  • \n
  • Setting a pin INPUT:

    \n
    echo in > /sys/class/gpio/gpio40/direction
    \n
  • \n
  • Reading the value from an INPUT pin (returns 1 for HIGH and 0 for LOW):

    \n
  • \n
  • cat /sys/class/gpio/gpio40/value
    \n
  • \n
\n

Controlling the GPIO with BoneScript

\n

You can use the following BoneScript commands to control the GPIO.

\n
    \n
  • Loading a BoneScript module:

    \n
    var b = require('bonescript');
    \n
  • \n
  • Setting a pin OUTPUT:

    \n
    b.pinMode(\"P9_14\", b.OUTPUT);
    \n
  • \n
  • Writing a pin HIGH:

    \n
    b.digitalWrite(\"P9_14\", b.HIGH);
    \n
  • \n
  • Writing a pin LOW:

    \n
    b.digitalWrite(\"P9_14\", b.LOW);
    \n
  • \n
  • Setting a pin INPUT:

    \n
    b.pinMode(\"P8_11\", b.INPUT);
    \n
  • \n
  • Reading the value from a digital INPUT pin (returns HIGH or LOW):

    \n
    b.digitalRead(\"P8_11\");
    \n
  • \n
  • Setting a pin for pulse-width modulation (PWM) with 50 percent duty cycle:

    \n
    b.pinMode('P9_14', b.OUTPUT);\nb.analogWrite('P9_14', 0.5);
    \n
  • \n
  • Reading the value from an analog INPUT pin (returns a value between 0 and 1):

    \n
  • \n
  • b.analogRead('P9_40');
    \n
  • \n
\n

Controlling the GPIO with Python

\n

You can use the following Python commands to control the GPIO.

\n
    \n
  • Importing Adafruits BeagleBone Input Output Library:

    \n
    import Adafruit_BBIO.GPIO as GPIO
    \n
  • \n
  • Setting a pin OUTPUT:

    \n
    GPIO.setup(\"P9_14\", GPIO.OUT)
    \n
  • \n
  • Writing a pin HIGH:

    \n
    GPIO.output(\"P9_14\", GPIO.HIGH)
    \n
  • \n
  • Writing a pin LOW:

    \n
    GPIO.output(\"P9_14\", GPIO.LOW)
    \n
  • \n
  • Setting a pin INPUT:

    \n
    GPIO.setup(\"P8_11\", GPIO.IN)
    \n
  • \n
  • Reading the value from a digital INPUT pin (returns HIGH or LOW):

    \n
    GPIO.input(\"P8_11\")
    \n
  • \n
  • Setting a pin for PWM with 50 percent duty cycle:

    \n
    import Adafruit_BBIO.PWM as PWM\nPWM.start(\"P9_14\", 50)
    \n
  • \n
  • Setting an analog INPUT:

    \n
    import Adafruit_BBIO.ADC as ADC\nADC.setup()
    \n
  • \n
  • Reading the value from an analog INPUT pin (returns a value between 0 and 1):

    \n
  • \n
  • analogReading = ADC.read(\"P9_40\")
    \n
  • \n
","description":"

Following is a handy reference that you can use to control and access your BeagleBones general purpose input/output (GPIOs) with the file system, BoneScript, and Python.

\n

Controlling the GPIO with the file system

\n

You can use the following commands to control the GPIO with the file system.

\n
    \n
  • Exporting a pin:

    \n
    echo 40 > /sys/class/gpio/export
    \n
  • \n
  • Setting a pin OUTPUT:

    \n
    echo out > /sys/class/gpio/gpio40/direction
    \n
  • \n
  • Writing a pin HIGH:

    \n
    echo 1 > /sys/class/gpio/gpio40/value
    \n
  • \n
  • Writing a pin LOW:

    \n
    echo 0 > /sys/class/gpio/gpio40/value
    \n
  • \n
  • Setting a pin INPUT:

    \n
    echo in > /sys/class/gpio/gpio40/direction
    \n
  • \n
  • Reading the value from an INPUT pin (returns 1 for HIGH and 0 for LOW):

    \n
  • \n
  • cat /sys/class/gpio/gpio40/value
    \n
  • \n
\n

Controlling the GPIO with BoneScript

\n

You can use the following BoneScript commands to control the GPIO.

\n
    \n
  • Loading a BoneScript module:

    \n
    var b = require('bonescript');
    \n
  • \n
  • Setting a pin OUTPUT:

    \n
    b.pinMode(\"P9_14\", b.OUTPUT);
    \n
  • \n
  • Writing a pin HIGH:

    \n
    b.digitalWrite(\"P9_14\", b.HIGH);
    \n
  • \n
  • Writing a pin LOW:

    \n
    b.digitalWrite(\"P9_14\", b.LOW);
    \n
  • \n
  • Setting a pin INPUT:

    \n
    b.pinMode(\"P8_11\", b.INPUT);
    \n
  • \n
  • Reading the value from a digital INPUT pin (returns HIGH or LOW):

    \n
    b.digitalRead(\"P8_11\");
    \n
  • \n
  • Setting a pin for pulse-width modulation (PWM) with 50 percent duty cycle:

    \n
    b.pinMode('P9_14', b.OUTPUT);\nb.analogWrite('P9_14', 0.5);
    \n
  • \n
  • Reading the value from an analog INPUT pin (returns a value between 0 and 1):

    \n
  • \n
  • b.analogRead('P9_40');
    \n
  • \n
\n

Controlling the GPIO with Python

\n

You can use the following Python commands to control the GPIO.

\n
    \n
  • Importing Adafruits BeagleBone Input Output Library:

    \n
    import Adafruit_BBIO.GPIO as GPIO
    \n
  • \n
  • Setting a pin OUTPUT:

    \n
    GPIO.setup(\"P9_14\", GPIO.OUT)
    \n
  • \n
  • Writing a pin HIGH:

    \n
    GPIO.output(\"P9_14\", GPIO.HIGH)
    \n
  • \n
  • Writing a pin LOW:

    \n
    GPIO.output(\"P9_14\", GPIO.LOW)
    \n
  • \n
  • Setting a pin INPUT:

    \n
    GPIO.setup(\"P8_11\", GPIO.IN)
    \n
  • \n
  • Reading the value from a digital INPUT pin (returns HIGH or LOW):

    \n
    GPIO.input(\"P8_11\")
    \n
  • \n
  • Setting a pin for PWM with 50 percent duty cycle:

    \n
    import Adafruit_BBIO.PWM as PWM\nPWM.start(\"P9_14\", 50)
    \n
  • \n
  • Setting an analog INPUT:

    \n
    import Adafruit_BBIO.ADC as ADC\nADC.setup()
    \n
  • \n
  • Reading the value from an analog INPUT pin (returns a value between 0 and 1):

    \n
  • \n
  • analogReading = ADC.read(\"P9_40\")
    \n
  • \n
","blurb":"","authors":[{"authorId":9270,"name":"Rui Santos","slug":"rui-santos","description":"","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9270"}},{"authorId":9271,"name":"Luis Miguel Costa Perestrelo","slug":"luis-miguel-costa-perestrelo","description":"","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9271"}}],"primaryCategoryTaxonomy":{"categoryId":33518,"title":"BeagleBone","slug":"beaglebone","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33518"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":null,"inThisArticle":[{"label":"Controlling the GPIO with the file system","target":"#tab1"},{"label":"Controlling the GPIO with BoneScript","target":"#tab2"},{"label":"Controlling the GPIO with Python","target":"#tab3"}],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":207579,"title":"BeagleBone For Dummies Cheat Sheet","slug":"beaglebone-for-dummies-cheat-sheet","categoryList":["technology","computers","hardware","beaglebone"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/207579"}},{"articleId":203333,"title":"7 Capes You Can Add to the BeagleBone","slug":"7-capes-you-can-add-to-the-beaglebone","categoryList":["technology","computers","hardware","beaglebone"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/203333"}},{"articleId":203332,"title":"4 Amazing Projects for the BeagleBone","slug":"4-amazing-projects-for-the-beaglebone","categoryList":["technology","computers","hardware","beaglebone"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/203332"}},{"articleId":145670,"title":"Comparing BeagleBone Black and Raspberry Pi","slug":"comparing-beaglebone-black-and-raspberry-pi","categoryList":["technology","computers","hardware","beaglebone"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/145670"}},{"articleId":144981,"title":"How to Connect the BeagleBone Black via Serial over USB","slug":"how-to-connect-the-beaglebone-black-via-serial-over-usb","categoryList":["technology","computers","hardware","beaglebone"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/144981"}}]},"hasRelatedBookFromSearch":true,"relatedBook":{"bookId":292900,"slug":"arduino-projects-for-dummies","isbn":"9781118551479","categoryList":["technology","computers","hardware","arduino"],"amazon":{"default":"https://www.amazon.com/gp/product/1118551478/ref=as_li_tl?ie=UTF8&tag=wiley01-20","ca":"https://www.amazon.ca/gp/product/1118551478/ref=as_li_tl?ie=UTF8&tag=wiley01-20","indigo_ca":"http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1118551478-item.html&cjsku=978111945484","gb":"https://www.amazon.co.uk/gp/product/1118551478/ref=as_li_tl?ie=UTF8&tag=wiley01-20","de":"https://www.amazon.de/gp/product/1118551478/ref=as_li_tl?ie=UTF8&tag=wiley01-20"},"image":{"src":"https://catalogimages.wiley.com/images/db/jimages/9781118551479.jpg","width":250,"height":350},"title":"Arduino Projects For Dummies","testBankPinActivationLink":"","bookOutOfPrint":false,"authorsInfo":"\n

Brock Craft is a Lecturer in Physical Computing at Goldsmiths, University of London in the Department of Computing.


Fresno Nightcrawlers, Your Hard Work And Dedication Does Not Go Unnoticed, David Soul Wife Helen Snell, How Much Is A Half Pint Of Jameson, Articles B