The OK LED can be controlled from user space software. Details here: Re: Can we control the on-board leds
Summarised from the above (all credit to BrianW):
The OK LED is available as
The kernel LED driver has "triggers" which let some other part of the kernel control the LED. The default trigger for the LED is '
mmc0', which makes it come on when the SD card is accessed.
root@raspberrypi:~# cat /sys/class/leds/led0/trigger
You can deactivate the
mmc0 trigger as follows:
echo none >/sys/class/leds/led0/trigger
The LED can be turned on and off using the '
brightness' file. The minimum brightness is 0, and the maximum is 255. As there is no variable brightness support, any value greater than 0 will turn the LED on.
echo 1 >/sys/class/leds/led0/brightness
echo 0 >/sys/class/leds/led0/brightness
Setting the brightness to 0 automatically sets the trigger to "none".
If you want the LED to go back to its default function:
echo mmc0 >/sys/class/leds/led0/trigger
There are a couple of kernel modules you can load up (
ledtrig_heartbeat) which will flash the LED for you.
echo heartbeat >/sys/class/leds/led0/trigger
Once you have turned off the
mmc0 trigger, you can use GPIO16 to control the LED. It's active-low, so you need to set the pin low to turn the LED on, and high to turn it off.
From Python, you can use the module
RPi.GPIO to control pin 16. There is also a C# driver.
import RPi.GPIO as GPIO
from time import sleep
# Needs to be BCM. GPIO.BOARD lets you address GPIO ports by periperal
# connector pin number, and the LED GPIO isn't on the connector
# set up GPIO output channel
# Wait a bit