Status of Ledborg
Forums:
Hi , I am new to Ledborg and python , and wondering is there a way to check on the status of the Ledborg.
Just after a way to echo back to the terminal what value the ledborg is at.
For example if the LedBorg is showing a red light value "200" is there a way to return to print a line back to the terminal saying the colour showing is red ?
Thank You
- Log in to post comments


piborg
Wed, 05/08/2013 - 00:37
Permalink
Reading the current LedBorg value
From Python:
LedBorg = open('/dev/ledborg', 'r') colour = LedBorg.read() LedBorg.close() print colourDirectly from a terminal window:
cat /dev/ledborgThis should return the code number (e.g. 200), if you want to return a colour name you will need some kind of decode of the colour number back to a name from python, e.g.
LedBorg = open('/dev/ledborg', 'r') colour = LedBorg.read() LedBorg.close() if colour == "200": name = "Red" elif colour == "222": name = "White" else: name = "?" print nameorcolourNames = { "200":"Red", "222":"White" } LedBorg = open('/dev/ledborg', 'r') colour = LedBorg.read() LedBorg.close() if colourNames.has_key(colour): name =colourNames[colour] else: name = "?" print nameHopefully that helps you :)
piborg
Mon, 05/13/2013 - 14:21
Permalink
WhatIsYourColour.py
Just in case you still want help with this, we put out a Mecha Monday script today for this purpose
WhatIsYourColour.py