Created
April 2, 2016 14:05
-
-
Save djhworld/8d000e2a40c83755c253cb939335bd7a to your computer and use it in GitHub Desktop.
This file contains 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 | |
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