Created
October 25, 2012 06:53
-
-
Save dweeber/3950942 to your computer and use it in GitHub Desktop.
Script to check for button press
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/bash | |
################################################# | |
# Switch Test #1 | |
# | |
# Sets up the GPIO 4 port to check for a button | |
# press. Loops until the button is pressed | |
# | |
# Ref: | |
# http://rpi.tnet.com/project/hardware/project001 | |
# | |
################################################# | |
# Setup the port First | |
/usr/local/bin/gpio -g mode 4 in | |
/usr/local/bin/gpio -g mode 4 up | |
# Loop Looking for a button press | |
while [ 1 ] | |
do | |
value=`/usr/local/bin/gpio -g read 4` | |
if [ $value -eq 0 ] | |
then | |
break | |
fi | |
sleep 1 | |
done | |
echo "We left the loop" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment