Home / Tutorials / BeagleBone Tutorial / Beaglebone Black: Controlling On-board LEDs

Beaglebone Black: Controlling On-board LEDs

In this post, I flashed a LED connected to one of the Beaglebone Black's GPIO pins. Here I will flash the user or on-board LEDs on the device using the same method we did on the external LED.

User LEDs

The Beaglebone Black has four blue LEDs, USR0 to USR3, in the corner near the reset button. You would see them immediately because they flash when you turn on the device. The purpose of the LEDs is to describe the current state of the Beaglebone Black:

USR0 is the one that blinks in a heartbeat pattern; 

USR1 lights when accessing the microSD card; 

USR2 lights during CPU activity and

US3 lights when the eMMC is accessed.

Accessing the LEDs

We can access the user LEDs via /sys/class/leds

Here we can see all the user LEDs (why is it named green?). Try opening an individual LED:

LED Brightness

I wonder what the current brightness of USR2 is... You can get that information by doing this:

It's 0 because it's turned off! To turn it on, echo 1 to brightness like this:

The USR2 LED (second closest to the LAN port) should light up.


You can also set when the user led acts via the trigger parameter. To know all the triggers for the USR2 LED, do this:

That's a lot of trigger events. There's trigger everytime a keyboard key is hit (kbd-capslock, kbd-ctrllock, etc), and when devices are accessed (usb-gadget, usb-host, mmc0, etc.). For now, let's try the timer trigger.  Let's say we want USR2 to turn on for a second then turn off. Here's how to do that:

If you do this again:

You will notice that timer is now enclosed in square brackets. This indicates the current trigger setting.

Try the heartbeat trigger to make it flash like USR0 or the default-on trigger to make it stay on!

C++ Code

Here's the C++ code for the Beaglebone Black to make USR2 turn on and off for a second for about four times:

Have any questions? Write a comment below! Happy coding!

Check Also

beaglebone black adc

Controlling a Servo Motor with BoneScript

Using the Beaglebone Black's PWM Bonescript also includes an analogWrite function which utilizes the 8 …

Leave a Reply

Your email address will not be published. Required fields are marked *