886 0 obj <> endobj And if for example I have a bunch of code in the while loop then it blinks again (assuming the time.sleep(1) represents code that takes a second to run): Is there anyway to say to a pin to be on constantly with Python ? It supports the GPIO, ADC, PWM, UART, SPI, I2C and eQEP modules, and also includes a number of additional libraries for added functionality. vU' 5VPePh IP9^9dx#iWi[. . Start by clicking Add device on the fleet summary. By the end of it, you should be ready to write your first Python program. Activate local mode on the device via the dashboard. Not sure about this but is Micropython a possibility. If you are looking for definitions of certain terms, refer to the glossary. Click the Authorize button, and head back to the terminal after the login Using GPIO, PWM and more with Python! [Optional] A 5VDC 1A power supply unit for the Beaglebone Black. This guide was first published on Jun 13, 2013. Please remember that this subscription will not result in you receiving any e-mail from us about anything other than the restocking of this item. It actually works. Using a 5V Stepper Motor with the RasPiRobot Board V2, Adafruit 2.7" eInk Display Breakouts and Shields, PiTFT Python + Pillow Animated Gif Player, Raspberry Pi E-Ink Event Calendar using Python, A Minority and Woman-owned Business Enterprise (M/WBE). Whether it's to pass that big test, qualify for that big promotion or even master that cooking technique; people who rely on dummies, rely on it to learn the critical skills and relevant information necessary for success. 1. Do you still have to use python2 for the i2c bus ? Programming the BeagleBone Black with Python. successful message appears. The languages i used are Python, Flask and HTML. Written by Justin Cooper, Adafruit Industries. You can find the device's IP address on the device dashboard page. These commands will require internet access. You can also wait for an edge. This is no good for our LED, we need the pin it is connected to to be an output, so type the command: Download File. It was last To create a release, use the balena push First-Fleet command replacing Currently recommended image: Debian 10.3 "Buster" IoT (2020-04-06) (default kernel is 4.19.x-ti) 565), Improving the copy in the close modal and post notices - 2023 edition, New blog post from our CEO Prashanth: Community is the future of AI. I was wondering what are some other GPIO Python libraries that people use. !J"x>N&2^ANDIExs0+ vP#Am2J^AF ,+qu2jN"Pde'2,e\NbPd@3GT'x(q"cNR< 5/Ob\" * Thank you in advance. Both the Beaglebone Black and Green use a Micro SD card. . Wait for writing of balenaOS to complete. Wait for the BeagleBone Black to finish flashing and shutdown. What I would like is to keep a white LED constantly on. I2C is only compatible with Python2 due to the python-smbus dependency. balenaCloud builds a custom balenaOS image configured for BeagleBone Black which allows the device to provision and join the new fleet you created automatically. . 65 Digital Pins at 3.3V. The first one is for GPIO: 4-channel I2C-safe Bi-directional Logic Level Converter, "The master in the art of living makes little distinction between work and play", Setting up IO Python Library on BeagleBone Black, Adafruit 1-Wire Thermocouple Amplifier - MAX31850K, 2.3" Monochrome 128x32 OLED Display Module, 1.5" & 2.4" Monochrome 128x64 OLED Display Module. Get Started with balenaCloud using BeagleBone Black and Python To subscribe to this RSS feed, copy and paste this URL into your RSS reader. The production OS does not facilitate the development workflow we'll be using. using the balena login command on the terminal: You will be asked to choose an authentication method, choose Web authorization which will You have been successfully subscribed to the Notification List for this product and will therefore receive an e-mail from us when it is back in stock! Connecting to your BeagleBone Black (SSH) The Adafruit_I2C.py module is now included in the Adafruit_BBIO library as a top-level module. Setup SPI drivers on Beaglebone Black 5. Once the page loads successully (you should see a green box that says "Your board is connected! You can use the following Python commands to control the GPIO. To continue learning, explore parts of the guide in more detail: Get Started with balenaCloud using BeagleBone Black and Python, Accessing a Device using a Gateway Device, Configuration list for {{ $device.name }}, differences between Development and Production images, troubleshooting guide for BeagleBone Black. Making statements based on opinion; back them up with references or personal experience. 8R (8`%ND'q wqyCWW`@j=CgtXQF#Ub Connect and share knowledge within a single location that is structured and easy to search. spi = SPI ( 0, 0) The BeagleBone Black (BBB) includes SPI0, as well as SPI1. This means that if the value is. HDMI, and the eMMC flash module take up quite a few of them by default. Developing the sample project: making changes and testing them on the device in real-time. Modified 4 years, 10 months ago. After saving the changes, you can observe balena CLI automatically start rebuilding only the parts of the Dockerfile that has been changed. The BeagleBone IO Python library was originally forked from the excellent MIT Licensed RPi.GPIO library written by Ben Croston. Hi @DTJF , do you have any more examples with libpruio lib for Python? You can see the progress of the device code updates on the device dashboard: After the download, you should now have a Python web server running on your device and see some logs on your dashboard. PWM | Setting up IO Python Library on BeagleBone Black | Adafruit Navigate to the index.html file present in the static directory of the project. "GPIO0_26". When I wrote python code I used the Adafruit _BBIO Library. >>> import Adafruit_BBIO.GPIO as GPIO. 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. A nice project to try is the balena-python-hello-world project. SPI import SPI. For blinking onboard leds try this example: Thanks for contributing an answer to Stack Overflow! To do so, follow the following steps: When complete, after a minute or two the device should appear on your balenaCloud dashboard, and you should now be ready to deploy some code. Please remember that this subscription will not result in you receiving any e-mail from us about anything other than the restocking of this item. Could a subterranean river or aquifer generate enough continuous momentum to power a waterwheel for the purpose of producing electricity? Each digital I/O pin has 8 different modes that can be selected, including GPIO. 2x I2C. You wouldn't want to do this though, as P9_1 is actually gnd! Content Discovery initiative April 13 update: Related questions using a Review our technical responses for the 2023 Developer Survey, Use different Python version with virtualenv, Random string generation with upper case letters and digits, How to upgrade all Python packages with pip, RuntimeWarnings with GPIO.setup and GPIO.cleanup not work with KeyboardInterrupt. To run balena CLI commands, open a command prompt: Click on the Windows Start Menu, type PowerShell, and then click on Windows PowerShell. You can also use the name of the pin to access it, which would be . 2. There are 2 x 46 pins available (well, not all of them are, but we'll get to that later) to use. >>> GPIO.setup ("P8_10", GPIO.OUT) At this point, the LED should still be off. I have not personally tested this lib. Other device types of the same architecture can also be picked to join the fleet. Select the type of network connection you'll be using: Ethernet Only or Wifi + Ethernet. I don not want to use circuit python as I have not like it as much as others mentioned. For example, pin 7 on header P8 is P8_7. Select an OS type of balenaOS, and you will see a list of available balenaOS versions with the latest preselected. And asynchronous code isnt my prefered technique, since I loose control over the exact timing. This page (Installation on Angstrom) was last updated on Jan 09, 2023. Please sign in to subscribe to this guide. endstream endobj 887 0 obj <>/Metadata 30 0 R/Pages 884 0 R/StructTreeRoot 58 0 R/Type/Catalog>> endobj 888 0 obj <>/MediaBox[0 0 595.32 841.92]/Parent 884 0 R/Resources<>/Font<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Rotate 0/StructParents 0/Tabs/S/Type/Page>> endobj 889 0 obj <>stream Beaglebone Black communicate with computers using USB cable. Once enabled, you can now use balena push again, but this time we will push directly to the local IP address of the device obtained via the dashboard. as a zipped file from GitHub, unzip it and open a terminal in the root of the extracted project directory. The Adafruit library can identify pins either by their location on the P8 and P9 headers, e.g. to Hello balena! https://elinux.org/EBC_Exercise_33_pygame, Derek Molloy code examples from Exploring Beaglebone book: For security reasons, an e-mail has been sent to you acknowledging your subscription. We will use the balena CLI for this. Beaglebone Black 2. Adafruit BBIO is an API to enable GPIO, PWM, ADC, UART, SPI and eQEP (Quadrature Encoder) hardware access from Python applications running on the Beaglebone. There are two different options at this time to import. updated on Jun 13, 2013. You'll know your code has been successfully compiled and built when our friendly unicorn mascot appears in your terminal: The release will then be downloaded and started by all the devices in the fleet. GPIO tutorial for the BeagleBone Black (Shallow Thoughts) Install py.test to run the tests. Building a surveillance system with a PIR sensor, the BeagleBone Black and Python.The BeagleBone Black is an outstanding tool . Copy Code. Please read the changelog. Note You need to be part of the gpio group of the OS running on the Beaglebone to be able to run GPIO code as a non-root user. Here is my test script: import Adafruit_BBIO.GPIO as GPIO import time P = "P8_11" GPIO.setup (P, GPIO.OUT) for i in xrange (100): if i % 2 == 0: GPIO.output (P, GPIO.HIGH) else: GPIO.output (P, GPIO.LOW) time.sleep (0.5) GPIO.cleanup () Thanks -=UPDATED=- It's a bug. To run balena CLI commands, open the Terminal app (. Take a note of the FLEET NAME as you'll need this in the next step to push the code to your device(s) in that fleet. Or you can use 1 or 0.:: On-board LEDs (USR0-USR3) are handled by LED class driver rather than the GPIO pin driver. hb```` B,@CZ\O3t800u``l5vn% @.' Dummies helps everyone be more knowledgeable and confident in applying what they know. You will be redirected back to this guide once you sign in, and can then subscribe to this guide. It waits for the end of the ADC sequence by waiting for /dev/uio5 event. 65 Digital Pins at 3.3V. Another option, that is non-blocking is to add an event to detect. config-pin is now used on the official BeagleBoard.org Debian Jessie and Stretch images to control pin mode (e.g. This is what you should be seeing. I am Revisiting the BeagleBone Black I havent used it in a long time. You signed in with another tab or window. If you are not able get the device to appear on the dashboard, then check out our troubleshooting guide for BeagleBone Black or try our support channels. Learning BeagleBone Python Programming | Packt Hub I encountered what might be a similar problem around the same time as you. Adafruit BBIO is an API to enable GPIO, PWM, ADC, UART, SPI and eQEP (Quadrature Encoder) hardware access from Python applications running on the Beaglebone. BeagleBone Black hardware details. I tried and tried using different spi overlays with exclusive use pins and ends up the board not booting . "P9_11", or by GPIO number, e.g. Connecting to the Internet. Remove the SD card from the host machine. This page (GPIO) was last updated on Jun 12, 2013. They have a different path in the /sys/ filesystem. Not all pins are necessarily available. You have been successfully subscribed to the Notification List for this product and will therefore receive an e-mail from us when it is back in stock! If, for any reason, you would like to unsubscribe from the Notification List for this product you will find details of how to do so in the e-mail that has just been sent to you! I found this lib. SPI | Setting up IO Python Library on BeagleBone Black | Adafruit The same build process as before is carried out, but this time instead of using the balena builders, the build takes place locally on the device itself. What is this brick with a round back and a stud on the side used for? Once you've imported it, you'll want to initialize the bus and device: Download File. Is it still good to use this even though it is not supported anymore.? This guide was first published on Jun 13, 2013. Choose a Development version of the OS. Ensure you are working from the root of the extracted project directory. Basic TensorFlow Object Recognition on any Computer ANO Directional Navigation and Scroll Wheel Rotary Python Debouncer Library for Buttons and Sensors, A Minority and Woman-owned Business Enterprise (M/WBE). You'll want to view the last page of this guide to see which pins are available to use. Viewed 371 times. Reading the value from an INPUT pin (returns 1 for HIGH and 0 for LOW): You can use the following BoneScript commands to control the GPIO. Sorry I was not clear in my question. To turn it on, type: We recommend using. Now, let's try making some changes to this project and testing them right on the device. This is how I managed to solve this question on the Beaglebone using Python and PyBBIO: #!/usr/bin/python # Circuit: # * A Piezo is connected to pin 12 on header P8. GPIO.setup("USR0", GPIO.OUT) GPIO.output("USR0", GPIO.HIGH) Dont work? After login, test the balena CLI by running the balena fleets command, which should return information about the fleet you created in the previous step. Thanks for the additional info but my question remains, if I run 'GPIO.output("P8_14", GPIO.HIGH)' it only turns on for a brief moment. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Open the file and change the title from Welcome to balena! - GPIO0_26 # * A button is connected to pin 45 on header P8. Create a fleet It's fairly simple to use. Extract the contents of the zip file to any folder you choose, for example, Visit our blog to find step-by-step tutorials for some, To publish what you will build or have already built, head over to, If you find yourself stuck or confused, help is just a. In the first example, you can see we used the "P8_10" key to designate which pin we'd like to set as the output, and the same pin in the second example, but using it's name "GPIO0_26". Does a password policy with a restriction of repeated characters increase security? To setup a digital pin as an output, set the output value to HIGH, and then cleanup after you're done: For blink leds or turn it on use USR0, USR1, USR2 and USR3. xXn8}# n@Q qN>( ;I"eJ}pq;fa^MGvu=cWwgSL~~,?`e"eXs)v}9k6g khUgs&aw_>Dvt)2N[@h^c$HiK{/4a[QD75`U0f7_Y/XDr~@ufW]*vW6dJOCuQ2:.98Vo) kGanTBh}t;Q5}x3a{{/c,XXc0yT1y. This command pushes the code to the balena builders, where it will be compiled, built, turned into a release, and applied to every device in the fleet. For security reasons, an e-mail has been sent to you acknowledging your subscription. Devices are added to fleets and can be moved between fleets at any time. Why does Acts not mention the deaths of Peter and Paul? Note: It is not possible to use SPI1 on the BeagleBone Black . What are some Good Python GPIO libraries for BBB By default, all the IO pins are set to be inputs. Importing Adafruit's BeagleBone Input Output Library: import Adafruit_BBIO.GPIO as GPIO. Please sign in to subscribe to this guide. python - How to generate sound signal through a GPIO pin on BeagleBone https://beagleboard.org/p/projects/tags/python, PyGame examples on elinux.org This guide was first published on Jun 13, 2013. 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. New versions of Adafruit_BBIO may break backwards compatibility. It's a Python web server that serves a static page on port 80. Then, you can see that there are pin numbers that start from 1, and go to 46. The fellow or group of persons that produced it also has a C lib. Insert the freshly flashed SD card into the BeagleBone Black. For security reasons, an e-mail has been sent to you acknowledging your subscription. You must connect to that pin some trigger logic if u want to do that. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Importing Adafruits BeagleBone Input Output Library: Setting a pin for PWM with 50 percent duty cycle: By entering your email address and clicking the Submit button, you agree to the Terms of Use and Privacy Policy & to receive electronic communications from Dummies.com, which may include marketing promotions, news and updates. 4-channel I2C-safe Bi-directional Logic Level Converter, "The master in the art of living makes little distinction between work and play". Good Day, I have a project on the beaglebone black that needs to use SPI and GPIO my problem is I can't seem to use GPIO as an input when I try to use the BB-SPIDEV0-00A0 overlay. - GPIO2_6 # Use a pull-down resistor (around 10K ohms . The BeagleBone Black is unique in that it has quite a few pins that are available on easy to use pin headers, as well as being a fairly powerful little system. Power up the BeagleBone Black while holding down the small button near the SD slot. Next, we will flash the downloaded image onto the device. You can access the channels by either referencing the pin "key" or the name. Yes that works with the LED on the actual BeagleBone. The BeagleBone Black is unique in that it has quite a few pins that are available on easy to use pin headers, as well as being a fairly powerful little system. Beaglebone Black LESSON 4: Digital Write to the GPIO Pins from Python "yhnCy"7k6(T"zctm"M#{{'|fghs4QQD|'N$)Vc-K/$jh>0:B`9te5BOb#kJWASShhI(IN% 7] Aa5gOHSO(3/58@l| z) In python to import the library you need to include the line: 1 import Adafruit_BBIO.GPIO as GPIO Once you have imported the library, you then need to setup your pin as an output pin: 1 GPIO.setup("P9_12", GPIO.OUT) Now if you want to set that pin high you can use the command: 1 GPIO.output("P8_10", GPIO.HIGH) GPIO General Purpose I/O interface This module provides access and control of pins set up as General Purpose I/O (GPIO). 2x I2C. Below are a few examples of using the Adafruit_BBIO.GPIO module. Find centralized, trusted content and collaborate around the technologies you use most. This page (Using the Adafruit_BBIO Library) was last updated on Jun 12, 2013. If you have some extra time, it may not be a bad idea to follow our installation guide for Angstrom, and flash your BeagleBone Black with the latest version. Version 1.2.0: update instructions for Python 3 and Debian 10.3. Remove the SD card from the BeagleBone Black. . Upgrade Adafruit_BBIO to latest version on PyPI: Using the library is very similar to the excellent RPi.GPIO library used on the Raspberry Pi. This tutorial shows you how to do digital writes to your GPIO pins on the Beaglebone Black. The interupt settings are in member structure Pruio::IntInit. The Adafruit library has changed, and the instructions have been updated. Follow the instructions below to install balenaCLI for the operating system available on your system. This entry is part 4 of 4 in the series Getting Started with BeagleBone Black. You will be redirected back to this guide once you sign in, and can then subscribe to this guide. BeagleBone IO Python library is released under the MIT License. You can also set pins as inputs as follows: Once you've done that, you can access the input value in a few different ways. When the download completes, you should have a zipped image file with a name like balena-First-Fleet-beaglebone-black-2.80.3+rev1-v12.7.0.img.zip. Finally, click the Download balenaOS button. Character LCD with Raspberry Pi or BeagleBone Black If I run the following code the LED turns on briefly ad then turns off again. How to Control BeagleBone's GPIOs - dummies All Rights Reserved, Smart Home with Raspberry Pi, ESP32, and ESP8266, MicroPython Programming with ESP32 and ESP8266, how to modify a cheap PIR motion sensor to operateat 3.3V, [eBook] Build Web Servers with ESP32 and ESP8266 (2nd Edition), Build a Home Automation System from Scratch , Home Automation using ESP8266 eBook and video course , ESP8266 NodeMCU Relay Module Control AC Appliances (Web Server), Build an All-in-One ESP32 Weather Station Shield, ESP8266 NodeMCU Access Point (AP) for Web Server, Build Web Servers with ESP32 and ESP8266 . import Adafruit_BBIO.GPIO as GPIO import time GPIO.setup("P8_14", GPIO.OUT) GPIO.output("P8_14", GPIO.HIGH) I have tried the following: GPIO General Purpose I/O interface Adafruit-BBIO documentation For more detailed information, visit the detailed Linux installation instructions. Using the Adafruit_BBIO library with the BeagleBone Black (BBB) is fairly simple, especially if you're familiar with the RPi.GPIO library for the Raspberry Pi. So, to access the first pin on P9, you'd use "P9_1". Setting up IO Python Library on BeagleBone Black - Adafruit Learning System https://circuitpython.org/blinka/beaglebone_black/, 14 BeagleBone Python projects 0. This means that many of the popular Python libraries built for the Raspberry Pi, will now just work on the BeagleBone Black if they are using I2C, such as the BMP085 sensor library. Is it still good to use this even though it is not supported anymore.? h_k0oEB $i >e>Ilwd~'. Not the answer you're looking for? I prefer to poll for an event, its much faster than an interrupt with all its overhead. The first, and easiest way is just polling the inputs, such as in a loop that keeps checking them: You can also wait for an edge. hbbd```b``"k3d>"Ys$i ?f#3+H(? Anyhow, you can find an example for handling an event in function Pruio::mm_start(). First-Fleet with the name of your fleet. You can use the following commands to control the GPIO with the file system. The wait_for_edge method is blocking, and will wait until something happens: He was a Partner at the design firm TinkerLondon, where he introduced the Arduino into the UK along with its creator, Massimo Banzi.

","authors":[{"authorId":9224,"name":"Brock Craft","slug":"brock-craft","description":"

Brock Craft is a Lecturer in Physical Computing at Goldsmiths, University of London in the Department of Computing. Adafruit Beaglebone I/O Python API. You need to keep it pressed until the blue LEDs start flashing wildly. I am using python to programm the GPIO and other hardware functionalities of BBB.I drawn the windows and menus using Glade.I want to link my hardware program written in python to this GUI.ie if I click LED ON button it should be lighted on.So how can I link the GUI created using Python to my . 4-channel I2C-safe Bi-directional Logic Level Converter, "The master in the art of living makes little distinction between work and play". In this guide, we will help you get started with balenaCloud by: Once you've completed this getting started guide to balena, you'll be equipped with the fundamentals needed to continue developing your application using balenaCloud and be on the path to deploying fleets of devices to production. PyBBIO is a Python library for Arduino-style hardware IO support on the BeagleBone and BeagleBone Black. 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. This post was written by Rui Santos and Lus Perestrelo authors of BeagleBone For Dummies *. Please remember that this subscription will not result in you receiving any e-mail from us about anything other than the restocking of this item. Controlling the GPIO with Python. When reporting issues, plesae run the following script which will print the system configuration: This script should be present for any Debian or Ubunut image downloaded from: Triac diode for example - the simplest. {"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.
1958 Gold Sovereign Value In Canadian Dollars, Is It Legal To Kill Raccoons In Texas, Kevin Sinfield Wedding, Articles B