Created
June 26, 2020 15:48
-
-
Save clcollins/a79670ed298f097e11b492009dad3043 to your computer and use it in GitHub Desktop.
Raspberry Pi LED Identifier
This file contains hidden or 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 | |
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