Before writing a Python program to control an LED, you can try some experiments from the Python console to control the LED's color and make sure that everything is working.

To launch the Python Console type:
# python
Python 2.7.3 (default, Apr  3 2013, 21:37:23) 
[GCC 4.7.3 20130205 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
First, we need to import the library, in particular its PWM feature that will allow us to control the brightness of the three color channels. so enter the command:
>>> import Adafruit_BBIO.PWM as PWM
To turn on the red component of the LED type:
>>> PWM.start("P8_13", 0)
Next turn on the Green by doing:
>>> PWM.start("P8_19", 0)
The LED should now look yellow / orange.

Finally lets turn on the blue channel using:
>>> PWM.start("P9_14", 0)
The LED should now be whitish in color as all three color channels are at full brightness.

Lets now turn all the LEDs off again by sending the following commands:
>>> PWM.stop("P8_13")
>>> PWM.stop("P8_19")
>>> PWM.stop("P9_14")

This guide was first published on Jul 09, 2013. It was last updated on Jul 09, 2013.

This page (The Python Console) was last updated on Jul 09, 2013.

Text editor powered by tinymce.