Writing a Program

Author Gravatar Image SIMON MONK
To make the LED flash, we are going to write a short Python program, so exit the Python Console by typing:
Copy Code
>>> exit()
This should take you back to the Linux prompt.
Enter the following command to create a new files called blink.py
Copy Code
# nano blink.py
Now paste the code below into the editor window.
Copy Code
import Adafruit_BBIO.GPIO as GPIO
import time

GPIO.setup("P8_10", GPIO.OUT)

while True:
    GPIO.output("P8_10", GPIO.HIGH)
    GPIO.output("P8_10", GPIO.LOW)
Save and exit the editor using CTRL-x and the Y to confirm.

To start the program, enter the command:
Copy Code
# python blink.py
When you want to stop the blinking, use CTRL-c to exit the program.
Last updated on 2015-04-02 at 02.30.09 AM Published on 2013-06-17 at 02.17.30 PM