Friday, November 22, 2013

Control the on-board LED on Raspberry Pi

There are 5 on-board LEDs on Raspberry Pi. One of them (marked OK or ACT) can be programmed as GPIO. It's connected GPIO16, usually SD card access indicator.


by default, it is set triggered by mmc0. It can be checked with the command:

# cat /sys/class/leds/led0/trigger
none [mmc0] timer oneshot heartbeat backlight gpio cpu0 default-on

In order to program it as GPIO, remove the trigger with the command:
# echo none >/sys/class/leds/led0/trigger

Then, to turn on the LED, enter the command:
# echo 1 >/sys/class/leds/led0/brightness

Then, to turn off the LED, enter the command:
# echo 0 >/sys/class/leds/led0/brightness

After that, resume the trigger by mmc0 with command (or reboot):
# echo mmc0 >/sys/class/leds/led0/trigger

Control the on-board LED on Raspberry Pi
Control the on-board LED on Raspberry Pi


In my experience, it cannot be perform using sudo, you have to login as root. To login as root, refer to last post "Set password of root".

Related:

3 comments:

raspberry_pi_freak said...

Works with sudo as well, as follows:
sudo sh -c "echo 0 > /sys/class/leds/led0/brightness"
sudo sh -c "echo 1 > /sys/class/leds/led0/brightness"

Andr.oid Eric said...

thanks for your info:)

Fernando said...

Hi, I would like to mount an external LED to monitorize the ACT LED onboard because is not very confortable to check this LED when the Raspi is a few meters away or enclosed in its box. You say that this LED is connected GPIO 16 but, Can I connect directly an external LED to this pin to get a "reply" of the ACT LED?