Before writing a Python program to control an LED, you can try some experiments from the Python console to control the LED.

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, so enter the command:
>>> import Adafruit_BBIO.GPIO as GPIO
By default, all the IO pins are set to be inputs. This is no good for our LED, we need the pin it is connected to to be an output, so type the command:
>>> GPIO.setup("P8_10", GPIO.OUT)
At this point, the LED should still be off. To turn it on, type:
>>> GPIO.output("P8_10", GPIO.HIGH)
Turn it off again by typing:
>>> GPIO.output("P8_10", GPIO.LOW)

This guide was first published on Jun 17, 2013. It was last updated on Jun 17, 2013.

This page (The Python Console) was last updated on Jun 17, 2013.

Text editor powered by tinymce.