Skip to content

Instantly share code, notes, and snippets.

@ronivaldo
Forked from taktran/rpi-led-notes.md
Created April 15, 2018 04:58
Show Gist options
  • Save ronivaldo/4f87feafc133dd5b8e5a3b1219283c0e to your computer and use it in GitHub Desktop.
Save ronivaldo/4f87feafc133dd5b8e5a3b1219283c0e to your computer and use it in GitHub Desktop.
Controlling Raspberry Pi 2 LEDs

Commands for controlling the Raspberry Pi 2 LEDs.

See rpi-leds for a node module that does this.

Power (PWR) LED

  • OK (ACT) LED = led0
  • Power (PWR) LED = led1

Allow access

echo gpio | sudo tee /sys/class/leds/led0/trigger
echo gpio | sudo tee /sys/class/leds/led1/trigger

Heartbeat effect

echo heartbeat | sudo tee /sys/class/leds/led0/trigger
echo heartbeat | sudo tee /sys/class/leds/led1/trigger

Timer effect

echo timer | sudo tee /sys/class/leds/led0/trigger
echo timer | sudo tee /sys/class/leds/led1/trigger

Turn on/off

echo 1 | sudo tee /sys/class/leds/led0/brightness
echo 0 | sudo tee /sys/class/leds/led0/brightness

echo 1 | sudo tee /sys/class/leds/led1/brightness
echo 0 | sudo tee /sys/class/leds/led1/brightness

Revert back to default setting

echo input | sudo tee /sys/class/leds/led1/trigger
echo mmc0 | sudo tee /sys/class/leds/led0/trigger

Notes

Resources

LED trigger original values:

pi@raspberrypi ~ $ cat /sys/class/leds/led1/trigger
none mmc0 timer oneshot heartbeat backlight gpio cpu0 cpu1 cpu2 cpu3 default-on [input] rfkill0
pi@raspberrypi ~ $ cat /sys/class/leds/led0/trigger
none [mmc0] timer oneshot heartbeat backlight gpio cpu0 cpu1 cpu2 cpu3 default-on input rfkill0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment