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-05-04 at 04.27.11 PM Published on 2013-06-17 at 10.17.30 AM