Skip to content

Instantly share code, notes, and snippets.

@djhworld
Created April 2, 2016 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djhworld/8d000e2a40c83755c253cb939335bd7a to your computer and use it in GitHub Desktop.
Save djhworld/8d000e2a40c83755c253cb939335bd7a to your computer and use it in GitHub Desktop.
#!/bin/bash
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
# test devised by gordonDrogon
function testpin {
pin=$1
echo -n "Testing GPIO pin #$pin..."
gpio mode $pin in
gpio mode $pin up
upVal=`gpio read $pin`
if [ "$upVal" != 1 ]; then
echo "${RED}[ERROR] - Failed to read '1' on PIN UP${RESET}"
return
fi
gpio mode $pin down
downVal=`gpio read $pin`
if [ "$downVal" != 0 ]; then
echo "${RED}[ERROR] - Failed to read '0' on PIN DOWN${RESET}"
return
fi
echo "${GREEN}[OK]${RESET}"
}
# PINS 8 and 9 ignored
pins=( 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 21 22 23 24 25 26 27 28 29 30 31 )
for i in "${pins[@]}"; do
testpin $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment