-
Notifications
You must be signed in to change notification settings - Fork 17
/
INSTALL.txt
53 lines (41 loc) · 1.57 KB
/
INSTALL.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
If you are using armbian on NanoPi Neo/Neo2:
1. clone repository and install to your home dir
git clone https://github.com/auto3000/RPi.GPIO_NP
cd RPi.GPIO_NP
2. install library
python3 setup.py install
or if you are using python 2.x
python2 setup.py install
3. Test installation. Run python console and try to import RPi.GPIO
python
>>> import RPi.GPIO as GPIO
if above command didn't throw error everything should be ok.
If you received:
File "<stdin>", line 1, in <module>
ImportError: No module named 'RPi.GPIO'
try:
>>> import RPi._GPIO
If you still get error something went wrong. Try to reboot and check if import works OK.
5. Run your first python code using GPIO:
create file test.py:
nano ./test.py
paste following code:
#!/usr/bin/python3
import RPi.GPIO as GPIO
import time
led = 12
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(led,GPIO.OUT)
i=0
while i<10:
print("LED on")
GPIO.output(led,GPIO.HIGH)
time.sleep(1)
print("LED off")
GPIO.output(led,GPIO.LOW)
time.sleep(1)
i=i+1
save file with ctrl+x and run the code:
sudo ./test.py
please remeber /dev/mem is writeprotected under Armbian and only root can access this device. This feature prevents anyone (even those in kmem group) to access GPIO ports! Original RPi.GPIO library under raspbian use /dev/gpiomem that allow anyone access to gpio memory connected to GPIO and forbids access to other addresses. At the moment there is no solution to freely access GPIO ports.