By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. Please read the changelog. I don not want to use circuit python as I have not like it as much as others mentioned. 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! "), you can click on the "GateOne SSH link to the upper left, in the sidebar. Building a surveillance system with a PIR sensor, the BeagleBone Black and Python.The BeagleBone Black is an outstanding tool . Finally, click the Download balenaOS button. Python threading class for GPIO Led blink. {"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.
\nYou can use the following commands to control the GPIO with the file system.
\nExporting a pin:
\necho 40 > /sys/class/gpio/export\n
Setting a pin OUTPUT:
\necho out > /sys/class/gpio/gpio40/direction\n
Writing a pin HIGH:
\necho 1 > /sys/class/gpio/gpio40/value\n
Writing a pin LOW:
\necho 0 > /sys/class/gpio/gpio40/value\n
Setting a pin INPUT:
\necho in > /sys/class/gpio/gpio40/direction\n
Reading the value from an INPUT pin (returns 1 for HIGH and 0 for LOW):
\ncat /sys/class/gpio/gpio40/value\n
You can use the following BoneScript commands to control the GPIO.
\nLoading a BoneScript module:
\nvar b = require('bonescript');\n
Setting a pin OUTPUT:
\nb.pinMode(\"P9_14\", b.OUTPUT);\n
Writing a pin HIGH:
\nb.digitalWrite(\"P9_14\", b.HIGH);\n
Writing a pin LOW:
\nb.digitalWrite(\"P9_14\", b.LOW);\n
Setting a pin INPUT:
\nb.pinMode(\"P8_11\", b.INPUT);\n
Reading the value from a digital INPUT pin (returns HIGH or LOW):
\nb.digitalRead(\"P8_11\");\n
Setting a pin for pulse-width modulation (PWM) with 50 percent duty cycle:
\nb.pinMode('P9_14', b.OUTPUT);\nb.analogWrite('P9_14', 0.5);\n
Reading the value from an analog INPUT pin (returns a value between 0 and 1):
\nb.analogRead('P9_40');\n
You can use the following Python commands to control the GPIO.
\nImporting Adafruits BeagleBone Input Output Library:
\nimport Adafruit_BBIO.GPIO as GPIO\n
Setting a pin OUTPUT:
\nGPIO.setup(\"P9_14\", GPIO.OUT)\n
Writing a pin HIGH:
\nGPIO.output(\"P9_14\", GPIO.HIGH)\n
Writing a pin LOW:
\nGPIO.output(\"P9_14\", GPIO.LOW)\n
Setting a pin INPUT:
\nGPIO.setup(\"P8_11\", GPIO.IN)\n
Reading the value from a digital INPUT pin (returns HIGH or LOW):
\nGPIO.input(\"P8_11\")\n
Setting a pin for PWM with 50 percent duty cycle:
\nimport Adafruit_BBIO.PWM as PWM\nPWM.start(\"P9_14\", 50)\n
Setting an analog INPUT:
\nimport Adafruit_BBIO.ADC as ADC\nADC.setup()\n
Reading the value from an analog INPUT pin (returns a value between 0 and 1):
\nanalogReading = ADC.read(\"P9_40\")\n
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.
\nYou can use the following commands to control the GPIO with the file system.
\nExporting a pin:
\necho 40 > /sys/class/gpio/export\n
Setting a pin OUTPUT:
\necho out > /sys/class/gpio/gpio40/direction\n
Writing a pin HIGH:
\necho 1 > /sys/class/gpio/gpio40/value\n
Writing a pin LOW:
\necho 0 > /sys/class/gpio/gpio40/value\n
Setting a pin INPUT:
\necho in > /sys/class/gpio/gpio40/direction\n
Reading the value from an INPUT pin (returns 1 for HIGH and 0 for LOW):
\ncat /sys/class/gpio/gpio40/value\n
You can use the following BoneScript commands to control the GPIO.
\nLoading a BoneScript module:
\nvar b = require('bonescript');\n
Setting a pin OUTPUT:
\nb.pinMode(\"P9_14\", b.OUTPUT);\n
Writing a pin HIGH:
\nb.digitalWrite(\"P9_14\", b.HIGH);\n
Writing a pin LOW:
\nb.digitalWrite(\"P9_14\", b.LOW);\n
Setting a pin INPUT:
\nb.pinMode(\"P8_11\", b.INPUT);\n
Reading the value from a digital INPUT pin (returns HIGH or LOW):
\nb.digitalRead(\"P8_11\");\n
Setting a pin for pulse-width modulation (PWM) with 50 percent duty cycle:
\nb.pinMode('P9_14', b.OUTPUT);\nb.analogWrite('P9_14', 0.5);\n
Reading the value from an analog INPUT pin (returns a value between 0 and 1):
\nb.analogRead('P9_40');\n
You can use the following Python commands to control the GPIO.
\nImporting Adafruits BeagleBone Input Output Library:
\nimport Adafruit_BBIO.GPIO as GPIO\n
Setting a pin OUTPUT:
\nGPIO.setup(\"P9_14\", GPIO.OUT)\n
Writing a pin HIGH:
\nGPIO.output(\"P9_14\", GPIO.HIGH)\n
Writing a pin LOW:
\nGPIO.output(\"P9_14\", GPIO.LOW)\n
Setting a pin INPUT:
\nGPIO.setup(\"P8_11\", GPIO.IN)\n
Reading the value from a digital INPUT pin (returns HIGH or LOW):
\nGPIO.input(\"P8_11\")\n
Setting a pin for PWM with 50 percent duty cycle:
\nimport Adafruit_BBIO.PWM as PWM\nPWM.start(\"P9_14\", 50)\n
Setting an analog INPUT:
\nimport Adafruit_BBIO.ADC as ADC\nADC.setup()\n
Reading the value from an analog INPUT pin (returns a value between 0 and 1):
\nanalogReading = ADC.read(\"P9_40\")\n
Brock Craft is a Lecturer in Physical Computing at Goldsmiths, University of London in the Department of Computing.