Difference between revisions of "RPi.GPIO : NanoPi NEO/NEO2/Air GPIO Programming with Python"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
Line 16: Line 16:
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
|Board Type||Image File||Download Link 1||Download Link 2
+
|Board Type||Image File||Download
 
|-
 
|-
|NanoPi NEO2|| nanopi-neo2_ubuntu-core-xenial_4.11.0_YYYYMMDD.img.zip||[https://pan.baidu.com/s/1eRDbeG6 baidu] ||[https://www.mediafire.com/folder/ah4i6w029912b/NanoPi-NEO2 MediaFire]  
+
  | NanoPi NEO2
 +
  | nanopi-neo2_friendly-core-xenial_4.11.0_YYYYMMDD.img.zip
 +
  | [http://dl.friendlyarm.com/NanoPi-NEO2 Download Link]
 
|-
 
|-
|NanoPi NEO||nanopi-neo_ubuntu-core-xenial_4.11.0_YYYYMMDD.img.zip||[http://pan.baidu.com/s/1boQFxN5 baidu]||[https://www.mediafire.com/folder/n5o8ihvqhnf6s/Nanopi-NEO MediaFire]  
+
  | NanoPi NEO
 +
  | nanopi-neo_friendly-core-xenial_4.11.0_YYYYMMDD.img.zip
 +
  | [http://dl.friendlyarm.com/Nanopi-NEO Download Link]
 
|-
 
|-
|NanoPi NEO Air||nanopi-neo-air_ubuntu-core-xenial_4.11.0_YYYYMMDD.img.zip||[https://pan.baidu.com/s/1kUMRucf baidu]||[https://www.mediafire.com/folder/sr5d0qpz774cs/NanoPi-NEO_Air MediaFire]  
+
  | NanoPi NEO Air
 +
  | nanopi-neo-air_friendly-core-xenial_4.11.0_YYYYMMDD.img.zip
 +
  | [http://dl.friendlyarm.com/NanoPi-NEO_Air Download Link]
 
|}
 
|}
  

Revision as of 04:24, 27 December 2017

查看中文

1 Introduction to RPi.GPIO_NP

For users to easily access GPIO with python FriendlyElec integrated RPi.GPIO in the UbuntuCore images for the NanoPi NEO/NEO2.
RPi.GPIO is a famous library in python for Raspberry Pi. FriendlyElec ported it to the NanoPi NEO/NEO2's UbuntuCore images and renamed it as RPi.GPIO_NP.
Most RPi.GPIO_NP's APIs are the same as those of RPi.GPIO and you can refer to https://pypi.python.org/pypi/RPi.GPIO for more details.

2 Install RPi.GPIO_NP

The RPi.GPIO_NP library is integrated in all the UbuntuCore images that are and will be released after June 5, 2017. Therefore for images released after this date no installation is needed.

3 Applicable Board Types and Image Files

Here is a table which lists all the board types and image files that work with RPi.GPIO. These image files are under the "official-ROMs" directories of the corresponding download links:

Board Type Image File Download
NanoPi NEO2 nanopi-neo2_friendly-core-xenial_4.11.0_YYYYMMDD.img.zip Download Link
NanoPi NEO nanopi-neo_friendly-core-xenial_4.11.0_YYYYMMDD.img.zip Download Link
NanoPi NEO Air nanopi-neo-air_friendly-core-xenial_4.11.0_YYYYMMDD.img.zip Download Link

4 Code Sample with RPi.GPIO_NP

Here is code sample on how to access a NanoPi NEO2. A Matrix - LED is connected to a NanoPi NEO2 in the following hardware setup:
WiringNP-LED-Demo
Pin Connection:

Matrix-LED NanoPi NEO2
S Pin7
V Pin4
G Pin6

The code sample shows how to make an LED blink in Python
Pin 7 is accessed in this code sample:

4.1 Code Sample in Python

Create a source file in Python:

vi led.py

Type in the following lines:

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
PIN_NUM = 7
 
GPIO.setmode(GPIO.BOARD)
GPIO.setup(PIN_NUM,GPIO.OUT)
while True:
        GPIO.output(PIN_NUM,True)
        time.sleep(1)
        GPIO.output(PIN_NUM,False)
        time.sleep(1)

Run led.py:

chmod +x led.py
sudo ./led.py

The LED module will blink if you do everything right.

5 Update Log

5.1 June-7-2017

  • Released English Version