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

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

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

To start the program, enter the command:
# python blink.py
When you want to stop the blinking, use CTRL-c to exit the program.

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

This page (Writing a Program) was last updated on Jun 17, 2013.

Text editor powered by tinymce.