User Tools

Site Tools


tutorials:common:using_python_program_control_gpios

This is an old revision of the document!


Using Python Program Control Gpios

About this Article

Abstract

Install python and lib

$sudo apt-get update
$sudo apt-get install python-dev
$wget http://dl.linux-sunxi.org/users/tom/pySUNXI-0.1.12.tar.gz
$tar zxf pySUNXI-0.1.12.tar.gz
$sudo python setup.py install

Connect the GPIO

Using the PD0 and VCC-5V for test

Write a sample program

#!/usr/bin/env python

import SUNXI_GPIO as GPIO
import time

RED_LED = GPIO.PD0

GPIO.init()
GPIO.setcfg(RED_LED, GPIO.OUT)

while True:
        GPIO.output(RED_LED, GPIO.HIGH)
        time.sleep(1)
        GPIO.output(RED_LED, GPIO.LOW)
        time.sleep(1)

Run program

$chmod +x blink.py
$sudo ./blink.py

The red led is blinking in cycle time.

See Also

tutorials/common/using_python_program_control_gpios.1405137054.txt.gz · Last modified: 2014/07/12 11:50 by allen