Created
July 12, 2012 15:46
-
-
Save pdp7/3098951 to your computer and use it in GitHub Desktop.
Raspberry Pi GPIO demo shell script
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
#!/bin/sh | |
# Updated for foo feature | |
# | |
# GPIO numbers should be from this list | |
# 0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25 | |
# Note that the GPIO numbers that you program here refer to the pins | |
# of the BCM2835 and *not* the numbers on the pin header. | |
# So, if you want to activate GPIO7 on the header you should be | |
# using GPIO4 in this script. Likewise if you want to activate GPIO0 | |
# on the header you should be using GPIO17 here. | |
# Set up GPIO 4 and set to output | |
echo "4" > /sys/class/gpio/export | |
echo "out" > /sys/class/gpio/gpio4/direction | |
# Set up GPIO 7 and set to input | |
echo "7" > /sys/class/gpio/export | |
echo "in" > /sys/class/gpio/gpio7/direction | |
# Write output | |
echo "1" > /sys/class/gpio/gpio4/value | |
# Read from input | |
cat /sys/class/gpio/gpio7/value | |
# Clean up | |
echo "4" > /sys/class/gpio/unexport | |
echo "7" > /sys/class/gpio/unexport |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment