Created
July 7, 2012 13:04
-
-
Save jhass/3066412 to your computer and use it in GitHub Desktop.
Some helper functions to work with the GPIO ports of the RPi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function export() { | |
| echo "$1" | sudo tee /sys/class/gpio/export | |
| sudo chgrp -RH --dereference users /sys/class/gpio/* | |
| sudo chmod -R g+w+r /sys/class/gpio/*/* | |
| } | |
| function unexport() { | |
| echo "$1" | sudo tee /sys/class/gpio/unexport | |
| } | |
| function output() { | |
| export $1 | |
| echo "out" > /sys/class/gpio/gpio$1/direction | |
| } | |
| function input() { | |
| export $1 | |
| echo "in" > /sys/class/gpio/gpio$1/direction | |
| } | |
| function enable() { | |
| echo "1" > /sys/class/gpio/gpio$1/value | |
| } | |
| function disable() { | |
| echo "0" > /sys/class/gpio/gpio$1/value | |
| } | |
| function display() { | |
| cat /sys/class/gpio/gpio$1/value | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment