Node.js GPIO 用 pi-gpio 模組終於成功了
查那麼多資料 終於找到一個正確解答了
到 /home/pi/quick2wire-gpio-admin
改完 在這目錄
make
sudo make install
******************************
/home/pi/node_modules/pi-gpio
改pi-gpio.js
var gpioAdmin = "gpio-admin",
sysFsPathOld = "/sys/devices/virtual/gpio", // pre 3.18.x kernel
sysFsPathNew = "/sys/class/gpio", // post 3.18.x kernel
sysFsPath;
var gpioAdmin = "gpio-admin",
sysFsPathOld = "/sys/class/gpio", // pre 3.18.x kernel
sysFsPathNew = "/sys/class/gpio", // post 3.18.x kernel
sysFsPath;
/home/pi/node_modules
沒事 怎麼會改路徑呢?
使用pi-gpio控制树莓派GPIO
跑不起來 跟他說的一樣到 /home/pi/quick2wire-gpio-admin
打开之前clone下来的quick2wire-gpio-admin/src/gpio-admin.c文件,将第30行左右的
修改为
改完 在這目錄
make
sudo make install
******************************
/home/pi/node_modules/pi-gpio
改pi-gpio.js
var gpioAdmin = "gpio-admin",
sysFsPathOld = "/sys/devices/virtual/gpio", // pre 3.18.x kernel
sysFsPathNew = "/sys/class/gpio", // post 3.18.x kernel
sysFsPath;
var gpioAdmin = "gpio-admin",
sysFsPathOld = "/sys/class/gpio", // pre 3.18.x kernel
sysFsPathNew = "/sys/class/gpio", // post 3.18.x kernel
sysFsPath;
**************************************************
var gpio = require("pi-gpio");
gpio.open(40, "output", function(err) { // Open pin 16 for output
gpio.write(40, 1, function() { // Set pin 16 high (1)
gpio.close(40); // Close pin 16
});
});
終於亮了
原來 npm install pi-gpio
發現都是裝在/home/pi/node_modules
git clone git://github.com/quick2wire/quick2wire-gpio-admin.git
cd quick2wire-gpio-admin
make
sudo make install
sudo adduser $USER gpio
cd quick2wire-gpio-admin
make
sudo make install
sudo adduser $USER gpio
做這動作 才會有 quick2wire-gpio-admin 這目錄
留言
張貼留言