Skip to content

Instantly share code, notes, and snippets.

@clcollins
Created June 26, 2020 15:48
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 clcollins/a79670ed298f097e11b492009dad3043 to your computer and use it in GitHub Desktop.
Save clcollins/a79670ed298f097e11b492009dad3043 to your computer and use it in GitHub Desktop.
Raspberry Pi LED Identifier
#!/bin/bash
set -o errexit
set -o nounset
trap quit INT TERM
COUNT=0
if ! [ $(id -u) = 0 ]; then
echo "Must be run as root."
exit 1
fi
LED="/sys/class/leds/led0"
if [[ ! -d $LED ]]
then
echo "Could not find an LED at ${LED}"
echo "Perhaps try '/sys/class/leds/ACT'?"
exit 1
fi
function quit() {
echo mmc0 >"${LED}/trigger"
}
echo -n "Blinking Raspberry Pi's LED - press CTRL-C to quit"
echo none >"${LED}/trigger"
while true
do
let "COUNT=COUNT+1"
if [[ $COUNT -lt 30 ]]
then
echo 1 >"${LED}/brightness"
sleep 1
echo 0 >"${LED}/brightness"
sleep 1
else
quit
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment