ทดสอบที่ GPIO 2
Solution 1 (wiring PI)
sudo apt-get install git-core
git clone git://git.drogon.net/wiringPi
cd wiringPi
git pull origin
./build
gpio -v
gpio -g mode 2 out
gpio -g write 2 1
gpio -g write 2 0
|
Link>>https://www.unzeen.com/article/2179/
Solution 2 (Shell script)
echo 2 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio2/direction
echo 1 > /sys/class/gpio/gpio2/value
echo 0 > /sys/class/gpio/gpio2/value
echo 2 > /sys/class/gpio/unexport
Solution 3 (python script)
$ sudo apt-get install python-dev
$ sudo apt-get install python-pip
$ sudo apt-get install python-rpi.gpio
nano gpio-on.py
#!/usr/bin/env python
# Turn on GPIO 2
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(2,GPIO.OUT)
GPIO.output(2,GPIO.HIGH)
nano gpio-off.py
#!/usr/bin/env python
# Turn on GPIO 2
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(2,GPIO.OUT)
GPIO.output(2,GPIO.LOW)
Link>>>http://www.arduitronics.com/article/raspberry-pi-connect-to-the-real-world-gpio-part-2
Link>>>http://www.sathittham.com/raspberry-pi/rpi-ep-4/
Link>>>http://www.ezenow.com/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%B1%E0%B9%88%E0%B8%87%E0%B9%80%E0%B8%9B%E0%B8%B4%E0%B8%94-%E0%B8%9B%E0%B8%B4%E0%B8%94-led-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-python-gpio/
แถม Blink ที่ GPIO 2
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(2, GPIO.OUT)
while 1:
GPIO.output(2, True)
time.sleep(0.2)
GPIO.output(2, False)
time.sleep(0.2)
GPIO.cleanup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น