Simple Power Indicator Script?


Hi, I just purchased a LEDBORG however my python skills are limited. I was wondering how a basic script to have the led turn on once the unit is powered on would look.

Basically when the unit turns on, I would like a blue light to turn on and remain until it is powered off.


I'm currently working on it through Raspbian but I mainly use the Pi for Retropie.

piborg's picture

This should be nice and simple to do :)

First you want to create a script which sets the LedBorg to blue.
This can be based on LedBorg: lesson 1, but you do not need the delay or to turn the LedBorg off at the end.

You should end up with something like this:

#!/usr/bin/env python
# Import the library functions we need
import time
import wiringpi2 as wiringpi
# Setup the LedBorg GPIO pins
wiringpi.pinMode(PIN_RED, wiringpi.GPIO.OUTPUT)
wiringpi.pinMode(PIN_GREEN, wiringpi.GPIO.OUTPUT)
wiringpi.pinMode(PIN_BLUE, wiringpi.GPIO.OUTPUT)
# Set the colour channels (1 is on, 0 is off)
red = 0
green = 0
blue = 1
# Set the LedBorg colour
wiringpi.digitalWrite(PIN_RED, red)
wiringpi.digitalWrite(PIN_GREEN, green)
wiringpi.digitalWrite(PIN_BLUE, blue)
print 'LedBorg on'

I would recommend making the file in the cd ~/ledborg directory. Save it as something like

Next edit the startup script for the pi: sudo nano /etc/rc.local. You want to add a new line just above the exit command to run this new script.

The bottom of the file should end up looking something like this:

sudo /home/pi/ledborg/ &
exit 0

At this point the blue LED should come on when the Raspberry Pi is started :)

From memory that is all you need to do, I think the GPIO pins are switched off when the Raspberry Pi is shutdown anyway, which will make the LedBorg turn off.

Thanks brah. I'll try it tomorrow.

Greatly appreciate your help dude.

Subscribe to Comments for "Simple Power Indicator Script?"