LedBorg arrives: time for some pretty GPIO-driven colours
29/11/2012 in: Tutorials
Yeay! I bought a LedBorg recently from PiBorg (only cost a few quid) and it has proven very straightforward to set up and use. LedBorg is essentially 3 LEDs on a very small (as in VERY _small_) expansion board for the Raspberry Pi. It is about the width, and half the length of my index finger making it possibly the teeniest hardware add-on I have every installed.
LedBorg’s LEDs can be set to off, low or high for each of the red, green and blue diodes. In combination this can be used to generate up to 26 colours. The setup instructions are clear and easy to follow. Just make sure that if you have a 512MB Raspberry Pi that you follow the Rev 2 instructions that are on the page.
Changing the colour is as easy as issuing the following from the terminal:
echo “RGB” > /dev/ledborg
replacing RGB with the off (0), low (1) or high (2) value for each of the red, green and blue diodes.
A few examples:
White
echo “222” > /dev/ledborg
(all LEDs at maximum output)
Black
echo “000” > /dev/ledborg
(all LEDs are off - strictly speaking the LedBorg is not actually outputting black... it is off)
Red
echo “200” > /dev/ledborg
Darker Red
echo “100” > /dev/ledborg
(appears less intense than full Red’s 200)
Orange
echo “220” > /dev/ledborg
Magenta
echo “202” > /dev/ledborg
Ok, so what practical uses can it be put to? Anything from a random colour generator, to colour waves to a CPU usage monitor. In the latter case the demo application that can be installed from PiBorg will change LedBorg’s colour output from Green to Red when the CPU spikes. Here’s an example of a random colour generator that I wrote quickly in Python:
import random, time
while True:
lbRed = random.randrange(0,3)
lbGreen = random.randrange(0,3)
lbBlue = random.randrange(0,3)
lbColour = str(lbRed)+str(lbGreen)+str(lbBlue)
LedBorg = open('/dev/ledborg', 'w')
LedBorg.write(lbColour)
del LedBorg
print lbColour
time.sleep(0.1)
This will pick a random value between 0 and 2 for each of the 3 diodes, set these values, causing the LedBorg to light up accordingly and then print the colour values selected to the terminal. Note that the range is specified as 0,3 as, from tutorialspoint the second value is the stop value and is excluded from the range. Try changing this to 0,2 and you will see that when run the program never output the number 2 (ie: high, LED on maximum) to the terminal. The Python docs do not explain this subtlety.
I have various plans for LedBorg using web.py, AJAX and my Android phone for remote control of my Pi when not connected via SSH and with no monitor plugged in. I can see LedBorg as a very handy gadget to give visual feedback that whatever I set on my Android phone has been so set on the Pi.
PiBorg also make the PiBorg (unsurprisingly), an interesting robot controller for the Raspberry Pi. Here’s a thought: if you cross a LedBorg with a PiBorg do you get a Cylon?
LedBorg’s LEDs can be set to off, low or high for each of the red, green and blue diodes. In combination this can be used to generate up to 26 colours. The setup instructions are clear and easy to follow. Just make sure that if you have a 512MB Raspberry Pi that you follow the Rev 2 instructions that are on the page.
Changing the colour is as easy as issuing the following from the terminal:
echo “RGB” > /dev/ledborg
replacing RGB with the off (0), low (1) or high (2) value for each of the red, green and blue diodes.
A few examples:
White
echo “222” > /dev/ledborg
(all LEDs at maximum output)
Black
echo “000” > /dev/ledborg
(all LEDs are off - strictly speaking the LedBorg is not actually outputting black... it is off)
Red
echo “200” > /dev/ledborg
Darker Red
echo “100” > /dev/ledborg
(appears less intense than full Red’s 200)
Orange
echo “220” > /dev/ledborg
Magenta
echo “202” > /dev/ledborg
Ok, so what practical uses can it be put to? Anything from a random colour generator, to colour waves to a CPU usage monitor. In the latter case the demo application that can be installed from PiBorg will change LedBorg’s colour output from Green to Red when the CPU spikes. Here’s an example of a random colour generator that I wrote quickly in Python:
import random, time
while True:
lbRed = random.randrange(0,3)
lbGreen = random.randrange(0,3)
lbBlue = random.randrange(0,3)
lbColour = str(lbRed)+str(lbGreen)+str(lbBlue)
LedBorg = open('/dev/ledborg', 'w')
LedBorg.write(lbColour)
del LedBorg
print lbColour
time.sleep(0.1)
This will pick a random value between 0 and 2 for each of the 3 diodes, set these values, causing the LedBorg to light up accordingly and then print the colour values selected to the terminal. Note that the range is specified as 0,3 as, from tutorialspoint the second value is the stop value and is excluded from the range. Try changing this to 0,2 and you will see that when run the program never output the number 2 (ie: high, LED on maximum) to the terminal. The Python docs do not explain this subtlety.
I have various plans for LedBorg using web.py, AJAX and my Android phone for remote control of my Pi when not connected via SSH and with no monitor plugged in. I can see LedBorg as a very handy gadget to give visual feedback that whatever I set on my Android phone has been so set on the Pi.
PiBorg also make the PiBorg (unsurprisingly), an interesting robot controller for the Raspberry Pi. Here’s a thought: if you cross a LedBorg with a PiBorg do you get a Cylon?
blog comments powered by Disqus
