Skip to content

Commit

Permalink
Problem: need a blink command
Browse files Browse the repository at this point in the history
Solution: add zoobab's shell script
  • Loading branch information
hintjens committed Mar 2, 2016
1 parent a603d9c commit f90beef
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions commands/blink
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /bin/sh
# Blink a LED
#
# blink [times] [sleep]
#
GPNR="1"
TIMES=$1
SLEEP=$2
test -z $TIMES && TIMES=1
test -z $SLEEP && SLEEP=0.2

GPPATH="/sys/class/gpio"
GPIODIR="${GPPATH}/gpio${GPNR}"

# export the GPIO pin
if [ -d "${GPIODIR}" ]; then
echo "${GPIODIR} found"
else
echo "${GPIODIR} not found, creating it"
echo ${GPNR} > ${GPPATH}/export
fi

echo "Initalize the GPIO direction"
echo out > ${GPIODIR}/direction

echo "Blinking loop..."
COUNTER=0
while [ $COUNTER -lt $TIMES ]; do
echo 1 > ${GPIODIR}/value
sleep $SLEEP
echo 0 > ${GPIODIR}/value
sleep $SLEEP
COUNTER=`expr $COUNTER + 1`
done

0 comments on commit f90beef

Please sign in to comment.