HomeBridgeで機器をコントロールするためのGPIOを使うため、wiringPiというものを使用します。
1.wiringPi のインストール
homebridge@raspberrypi:~ $ git clone git://git.drogon.net/wiringPi
Cloning into 'wiringPi'...
・
・
・
NOTE: To compile programs with wiringPi, you need to add:
-lwiringPi
to your compile line(s) To use the Gertboard, MaxDetect, etc.
code (the devLib), you need to also add:
-lwiringPiDev
to your compile line(s).
2.ビルド
homebridge@raspberrypi:~/wiringPi $ ./build
3.インストールされた内容の確認
homebridge@raspberrypi:~/wiringPi $ gpio -v
gpio version: 2.36
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
Type: Pi Zero, Revision: 03, Memory: 512MB, Maker: Sony
* Device tree is enabled.
*--> Raspberry Pi Zero Rev 1.3
* This Raspberry Pi supports user-level GPIO access.
3.現在の GPIO の状況を確認出来ます。
homebridge@raspberrypi:~/wiringPi $ gpio readall
+-----+-----+---------+------+---+-Pi Zero--+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 1 | ALT0 | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | ALT0 | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 1 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+-Pi Zero--+---+------+---------+-----+-----+
等幅フォントが選択出来ないのかな?
見難いですね。
raspberry pi 上ではちゃんと見えてます。
4.次がサーボモーターをコントロールするため、
ServoBlaster のインストール
homebridge@raspberrypi:~/wiringPi $
git clone git://github.com/richardghirst/PiBits.git
Cloning into 'PiBits'...
remote: Counting objects: 369, done.
remote: Total 369 (delta 5), reused 5 (delta 5), pack-reused 363
Receiving objects: 100% (369/369), 382.21 KiB | 121.00 KiB/s, done.
Resolving deltas: 100% (162/162), done.
Checking connectivity... done.
homebridge@raspberrypi:~/wiringPi $ cd PiBits/ServoBlaster/user
homebridge@raspberrypi:~/wiringPi/PiBits/ServoBlaster/user $ make servod
gcc -Wall -g -O2 -o servod servod.c mailbox.c -lm
homebridge@raspberrypi:~/wiringPi/PiBits/ServoBlaster/user $ sudo make install
[ "`id -u`" = "0" ] || { echo "Must be run as root"; exit 1; }
cp -f servod /usr/local/sbin
cp -f init-script /etc/init.d/servoblaster
chmod 755 /etc/init.d/servoblaster
update-rc.d servoblaster defaults 92 08
/etc/init.d/servoblaster start
homebridge@raspberrypi:~/wiringPi/PiBits/ServoBlaster/user $ ls -l
total 128
-rwxr-xr-x 1 homebridge homebridge 1207 Jan 7 12:16 init-script
-rw-r--r-- 1 homebridge homebridge 7602 Jan 7 12:16 mailbox.c
-rw-r--r-- 1 homebridge homebridge 2349 Jan 7 12:16 mailbox.h
-rw-r--r-- 1 homebridge homebridge 651 Jan 7 12:16 Makefile
-rwxr-xr-x 1 homebridge homebridge 68680 Jan 7 12:17 servod
-rw-r--r-- 1 homebridge homebridge 40027 Jan 7 12:16 servod.c
homebridge@raspberrypi:~/wiringPi/PiBits/ServoBlaster/user $
1.wiringPi のインストール
homebridge@raspberrypi:~ $ git clone git://git.drogon.net/wiringPi
Cloning into 'wiringPi'...
・
・
・
NOTE: To compile programs with wiringPi, you need to add:
-lwiringPi
to your compile line(s) To use the Gertboard, MaxDetect, etc.
code (the devLib), you need to also add:
-lwiringPiDev
to your compile line(s).
2.ビルド
homebridge@raspberrypi:~/wiringPi $ ./build
wiringPi Build script
=====================
・
・
3.インストールされた内容の確認
homebridge@raspberrypi:~/wiringPi $ gpio -v
gpio version: 2.36
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
Type: Pi Zero, Revision: 03, Memory: 512MB, Maker: Sony
* Device tree is enabled.
*--> Raspberry Pi Zero Rev 1.3
* This Raspberry Pi supports user-level GPIO access.
3.現在の GPIO の状況を確認出来ます。
homebridge@raspberrypi:~/wiringPi $ gpio readall
+-----+-----+---------+------+---+-Pi Zero--+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 1 | ALT0 | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | ALT0 | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 1 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+-Pi Zero--+---+------+---------+-----+-----+
4.次がサーボモーターをコントロールするため、
ServoBlaster のインストール
homebridge@raspberrypi:~/wiringPi $
git clone git://github.com/richardghirst/PiBits.git
Cloning into 'PiBits'...
remote: Counting objects: 369, done.
remote: Total 369 (delta 5), reused 5 (delta 5), pack-reused 363
Receiving objects: 100% (369/369), 382.21 KiB | 121.00 KiB/s, done.
Resolving deltas: 100% (162/162), done.
Checking connectivity... done.
homebridge@raspberrypi:~/wiringPi $ cd PiBits/ServoBlaster/user
homebridge@raspberrypi:~/wiringPi/PiBits/ServoBlaster/user $ make servod
gcc -Wall -g -O2 -o servod servod.c mailbox.c -lm
homebridge@raspberrypi:~/wiringPi/PiBits/ServoBlaster/user $ sudo make install
[ "`id -u`" = "0" ] || { echo "Must be run as root"; exit 1; }
cp -f servod /usr/local/sbin
cp -f init-script /etc/init.d/servoblaster
chmod 755 /etc/init.d/servoblaster
update-rc.d servoblaster defaults 92 08
/etc/init.d/servoblaster start
homebridge@raspberrypi:~/wiringPi/PiBits/ServoBlaster/user $ ls -l
total 128
-rwxr-xr-x 1 homebridge homebridge 1207 Jan 7 12:16 init-script
-rw-r--r-- 1 homebridge homebridge 7602 Jan 7 12:16 mailbox.c
-rw-r--r-- 1 homebridge homebridge 2349 Jan 7 12:16 mailbox.h
-rw-r--r-- 1 homebridge homebridge 651 Jan 7 12:16 Makefile
-rwxr-xr-x 1 homebridge homebridge 68680 Jan 7 12:17 servod
-rw-r--r-- 1 homebridge homebridge 40027 Jan 7 12:16 servod.c
homebridge@raspberrypi:~/wiringPi/PiBits/ServoBlaster/user $
コメント
コメントを投稿