2.10.1. Blinking an LEDΒΆ

LEDs can be accessed and controlled through the sysfs LED interface.

For example, the AM64x Starter Kit EVM has the following LEDs available in sysfs:

# ls /sys/class/leds
amber:activity    green:activity    green:activity_2  mmc0::  red:activity
amber:activity_1  green:activity_1  green:activity_3  mmc1::  red:activity_1

The following commands can be used to turn an LED on or off:

# echo 1 > /sys/class/leds/<led_name>/brightness
# echo 0 > /sys/class/leds/<led_name>/brightness

Where <led_name> can be any one of the LEDs listed under /sys/class/leds.

Something similar to the following can be put to a shell script to blink an LED (i.e., periodically turn the LED on/off):

for i in {1..10}
do
    echo 1 > /sys/class/leds/<led_name>/brightness
    sleep 0.5
    echo 0 > /sys/class/leds/<led_name>/brightness
    sleep 0.5
done

The following commands can be used to start or stop heartbeat blinking for an LED:

# echo heartbeat > /sys/class/leds/<led_name>/trigger
# echo none > /sys/class/leds/<led_name>/trigger