User Tools

Site Tools


tutorials:common:using_python_program_control_gpios

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tutorials:common:using_python_program_control_gpios [2014/07/12 11:50]
allen [Run program]
tutorials:common:using_python_program_control_gpios [2014/07/15 10:35] (current)
allen
Line 1: Line 1:
-====== Using Python Program Control ​Gpios ======+====== Using Python Program Control ​GPIOs ======
  
 <WRAP noprint><​WRAP left box 60%> <WRAP noprint><​WRAP left box 60%>
Line 9: Line 9:
  
 ===== Abstract ===== ===== Abstract =====
 +
 +
 +Here is the guide to show  that how to use python program control GPIOs .More others way to control can refer to http://​docs.cubieboard.org/​tutorials/​common/​gpio_on_lubuntu
  
  
Line 15: Line 18:
 $sudo apt-get update $sudo apt-get update
 $sudo apt-get install python-dev $sudo apt-get install python-dev
-$wget http://dl.linux-sunxi.org/users/tom/​pySUNXI-0.1.12.tar.gz+$wget http://dl.cubieboard.org/software/libs/​pySUNXI-0.1.12.tar.gz
 $tar zxf pySUNXI-0.1.12.tar.gz $tar zxf pySUNXI-0.1.12.tar.gz
 $sudo python setup.py install $sudo python setup.py install
Line 24: Line 27:
 ===== Connect the GPIO ===== ===== Connect the GPIO =====
  
-Using the PD0 and VCC-5V for test +Using the PD0 and VCC-5V for test.
  
 {{:​tutorials:​common:​193929q19liwbpuod9r4d9.png|}} {{:​tutorials:​common:​193929q19liwbpuod9r4d9.png|}}
Line 33: Line 36:
 ==== Write a sample program ==== ==== Write a sample program ====
 <​code>​ <​code>​
-    ​#​!/​usr/​bin/​env python +#​!/​usr/​bin/​env python
- +
-    import SUNXI_GPIO as GPIO +
-    import time+
  
-    RED_LED = GPIO.PD0+import SUNXI_GPIO as GPIO 
 +import time
  
-    GPIO.init() +RED_LED ​GPIO.PD0
-    GPIO.setcfg(RED_LEDGPIO.OUT) +
-        +
-    while True: +
-            GPIO.output(RED_LED,​ GPIO.HIGH) +
-            time.sleep(1) +
-            GPIO.output(RED_LED,​ GPIO.LOW) +
-            time.sleep(1)+
  
 +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)
 </​code>​ </​code>​
  
Line 55: Line 57:
  
 <​code>​ <​code>​
-    ​$chmod +x blink.py +$chmod +x blink.py 
-    $sudo ./blink.py+$sudo ./blink.py
 </​code>​ </​code>​
 The red led is blinking ​ in cycle time. The red led is blinking ​ in cycle time.
tutorials/common/using_python_program_control_gpios.txt · Last modified: 2014/07/15 10:35 by allen