Flash red LED

A simple bash script (and hopefully a useful example) that flashes the red indicator LED on and off (using GPIO) the specified number of times (this is probably more useful for 2-port boards, where the red LED is more visible than the 1-port boards).

Simply copy the attachment below into your Slackware's /usr/local/bin and make it executable:

$ chmod +x /usr/local/bin/flash_indicator

and then you can simply type the following to e.g. flash the red LED on and off 5 times.

$ flash_indicator 5

The script handles the 'GPIO setup' (exporting pins, etc.) for you, and when it's finished blinking the LED it carefully tries to revert things back to the way they were before the script was run. When "reverting things" this can cause an extra momentary flash of the LED, so if you don't want this then comment out all the lines after # Now restore the initial settings

If you want you can also specify a second argument as the 'flash period' (defaults to 0.25 seconds) e.g.

$ flash_indicator 3 1

for a slow flash or

$ flash_indicator 10 0.05

for a fast flash

I've got /usr/local/bin/flash_indicator 4 at the end of my /etc/rc.d/rc.local file so that I can tell when my bifferboard has finished booting :)

But if you wanted to you could obviously use different numbers of flashes or different flash speeds to indicate different things...