In this guide, we will toggle a user LED on the MinnowBoard step-by-step. This guide is for beginners who are just getting started with the MinnowBoard.
For information on 'Setting up a microSD card', 'Booting Angstrom' etc, please refer here
User LED on the MinnowBoard
There are a total of five LED(s) on the MinnowBoard - D11, D12, D13, D14, D15 as shown in Figure -1. Their functions have been listed in the table below:
|2||D12||microSD card activity/USER LED*|
Now, let us understand these functions in a bit more detail:
- Heartbeat: The Heartbeat LED blinks at a regular rate to indicate that the hardware is operating properly, and that the CPU hasn't locked up. This is useful in embedded systems where you may not always have a board connected to a display to confirm its operation.
- microSD Card Activity: This LED blinks when there is disk activity happening on the microSD card port.
- CPUHOT: When this LED is on, it indicates that the CPU temperature is abnormally high. This may suggest that the MinnowBoard is running in too hot of an environment, or that there is a problem with the CPU heatsink attachment. The MinnowBoard will shut off in the event that the CPU temperature reaches a level that could possibly damage itself, and CPUHOT represents a warning temperature before this state is reached.
- PWROK: This LED indicates that the power source is operating within required tolerances for the MinnowBoard.
So, there are two USER LED(s) on the MinnowBoard - D11 and D12 but by default they cannot be used as USER LED(s).
The user LED(s) are accessible via the user space in Linux at the location below on the filesystem:
There is one directory per user LED, named as shown below:
Here, led0 is D11, while led1 is D12. Inside each one of those directories, there is a file named "brightness". If you write a "1" or a "0" to this file, then you can control the status of that led, i.e. , toggle it ON or OFF respectively.
This is an optional section which you can read for further understanding. In a nutshell, we are trying to access the on board USER LED(s) via userspace in Linux. To be more precise we are using the sysfs interface. sysfs is a virtual filesystem which translates the hardware devices and busses attached to the system(board in our case) into a file system hierarchy that can be accessed from userspace. sysfs is generated by the kernel and always mounted at /sys. As discussed earlier, trigger for D11 and D12 LEDs has to be changed to make them function as USER LEDs. I would describe 'trigger' as the API used to link a LED to an 'event' in kernel space. Here, 'event' could be microSD card or Ethernet activity, heartbeat, power etc. To understand this better, take LED D11 for example. The trigger for D11 has been set by default to heartbeat. So, to use it as an USER LED, we have to change the trigger for it to 'none' as shown in Figure - 2 below:
Now let us control that LED!
To use D11 as USER LED, we need to change its default trigger. Type the following command in your terminal to accomplish this:
echo none > /sys/class/leds/minnow_led0/trigger
Now we are ready to toggle the LED. Type the following commands in your terminal as shown in Figure - 3(First one is for turning ON and latter for OFF):
echo 1 > /sys/class/leds/minnow_led0/brightness echo 0 > /sys/class/leds/minnow_led0/brightness
You should see the LED change state as shown below: