Basics

When the EV3 is booting, the LEDs flash amber (orange). When it is finished booting, they turn solid green. This functionality is hard-coded in the kernel and in Brickman.

After the boot is complete, you can control the LEDs yourself. The LEDs live in /sys/class/leds/.

$ ls /sys/class/leds/
ev3:left:green:ev3dev  ev3:right:green:ev3dev
ev3:left:red:ev3dev    ev3:right:red:ev3dev

You probably noticed that amber is missing here. We will get to that in a bit.

Each LED has its own attributes for controlling it. We are using the standard Linux LED device class, so there is a bunch of extra stuff that it not really useful. Let’s figure out what is…

$ ls /sys/class/leds/ev3:left\:green\:ev3dev
brightness  device  max_brightness  power subsystem  trigger  uevent

You only have to escape the colons using the backslash (\:) when using a command line shell. The actual directory name is ev3:left:green:ev3dev.

# turn the left green LED off
$ echo 0 > /sys/class/leds/ev3:left\:green\:ev3dev/brightness
# find out what the maximum brightness value is
$ cat /sys/class/leds/ev3:left\:green\:ev3dev/max_brightness
255
# turn the left green LED back on (255 means 100%)
$ echo 255 > /sys/class/leds/ev3:left\:green\:ev3dev/brightness
# dim the left green LED 1/2 way
$ echo 127 > /sys/class/leds/ev3:left\:green\:ev3dev/brightness

You you must be a member of the ev3dev group (or root) to be able to control the LEDs.

Triggers

Triggers can make the LED do interesting things.

$ cat /sys/class/leds/ev3:left\:green\:ev3dev/trigger
[none] mmc0 timer heartbeat default-on transient
legoev3-battery-charging-or-full legoev3-battery-charging legoev3-battery-full
legoev3-battery-charging-blink-full-solid rfkill0

What about amber/orange?

To make the LED amber, we just have to turn on both the red and green LEDs at the same time.

# make left LED illuminate amber
$ echo 255 > /sys/class/leds/ev3:left\:green\:ev3dev/brightness; echo 255 > /sys/class/leds/ev3:left\:red\:ev3dev/brightness
# turn off left LED
$ echo 0 > /sys/class/leds/ev3:left\:green\:ev3dev/brightness; echo 0 > /sys/class/leds/ev3:left\:red\:ev3dev/brightness

How does red + green make amber? If you open up your favorite paint program that has a color chooser where you can adjust the individual red, green and blue values, we can see what is going on. Make sure blue is on zero, then change red and green both to their maximum values. You get yellow. On the EV3, the red LED is a bit stronger than than the green LED, so both LEDs at max brightness appears orange (which we are calling amber just because it is “supposed” to be sort of yellow-ish). In your paint program, if you leave red at the maximum value and start decreasing green, the color will start to turn orange and then red. So, playing around with the brightness values a bit, we can actually get orange and yellow.

# make the left LED really orange
$ echo 180 > /sys/class/leds/ev3:left\:green\:ev3dev/brightness; echo 255 > /sys/class/leds/ev3:left\:red\:ev3dev/brightness
# make the left LED yellow (this shows us how much stronger the red led is!)
$ echo 255 > /sys/class/leds/ev3:left\:green\:ev3dev/brightness; echo 25 > /sys/class/leds/ev3:left\:red\:ev3dev/brightness