Skip to content

Instantly share code, notes, and snippets.

@dweeber
Created October 25, 2012 06:53
Show Gist options
  • Save dweeber/3950942 to your computer and use it in GitHub Desktop.
Save dweeber/3950942 to your computer and use it in GitHub Desktop.
Script to check for button press
#!/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