2.10.1. Blinking an LED#

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

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

# ls /sys/class/leds
am62-sk:green:heartbeat  mmc0::  mmc1::  out0  out1  out2  out3  out4  out5  out6  out7

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