{"id":1811,"date":"2015-12-04T06:28:35","date_gmt":"2015-12-03T21:28:35","guid":{"rendered":"https:\/\/hack.gpl.jp\/?p=1811"},"modified":"2015-12-04T06:28:35","modified_gmt":"2015-12-03T21:28:35","slug":"post-1811","status":"publish","type":"post","link":"https:\/\/hack.gpl.jp\/2015\/12\/04\/post-1811.html","title":{"rendered":"RasPi2 \u3067C\u306e\u738b\u9053\uff1f WiringPi"},"content":{"rendered":"

\u3068\u308a\u3042\u3048\u305a\u3001RasPi \u3067C \u3092\u691c\u7d22\u3057\u305f\u3089\u4e00\u756a\u6700\u521d\u306b\u30d2\u30c3\u30c8\u3057\u305f\u306e\u3067\u3001\u3053\u308c\u3067\u3002<\/p>\n

\n

\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb
http:\/\/wiringpi.com\/<\/a><\/p>\n

GITHUB<\/p>\n

https:\/\/github.com\/WiringPi<\/a><\/p>\n<\/blockquote>\n

Ruby \u3084 PHP \u3084Python \u306a\u3069\u306e\u30e9\u30c3\u30d1\u30fc\u3082\u3042\u308b\u3088\u3046\u3067\u3059\u3002\u3068\u308a\u3042\u3048\u305a\u3001c \u3067\u3002<\/p>\n

 <\/p>\n

\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3001INSTALL \u304b\u3001\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb\u30b5\u30a4\u30c8\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u3088\u3046\u306b\u3002build \u30b9\u30af\u30ea\u30d7\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

[root@pi wiringPi 12\/04 05:34:23]# .\/build \nwiringPi Build script\n=====================\n\n\nWiringPi Library\n[UnInstall]\n[Compile] wiringPi.c\n[Compile] wiringSerial.c\n[Compile] piHiPri.c\n[Compile] wiringShift.c\n[Compile] piThread.c\n[Compile] wiringPiSPI.c\n[Compile] softPwm.c\n[Compile] wiringPiI2C.c\n[Compile] softTone.c\n[Compile] mcp23008.c\n[Compile] mcp23016.c\n[Compile] mcp23017.c\n[Compile] mcp23s08.c\n[Compile] mcp23s17.c\n[Compile] pcf8574.c\n[Compile] sr595.c\n[Compile] mcp3002.c\n[Compile] pcf8591.c\n[Compile] mcp3004.c\n[Compile] mcp4802.c\n[Compile] mcp3422.c\n[Compile] max31855.c\n[Compile] max5322.c\n[Compile] sn3218.c\n[Compile] drcSerial.c\n[Compile] wpiExtensions.c\n[Link (Dynamic)]\n[Install Headers]\n[Install Dynamic Lib]\n\nWiringPi Devices Library\n[UnInstall]\n[Compile] ds1302.c\n[Compile] maxdetect.c\n[Compile] piNes.c\n[Compile] gertboard.c\n[Compile] piFace.c\n[Compile] lcd128x64.c\n[Compile] lcd.c\n[Compile] piGlow.c\n[Link (Dynamic)]\n[Install Headers]\n[Install Dynamic Lib]\n\nGPIO Utility\n[Compile] gpio.c\n[Compile] readall.c\n[Compile] pins.c\n[Link]\n[Install]\n\nAll Done.\n\nNOTE: To compile programs with wiringPi, you need to add:\n    -lwiringPi\n  to your compile line(s) To use the Gertboard, MaxDetect, etc.\n  code (the devLib), you need to also add:\n    -lwiringPiDev\n  to your compile line(s).\n\n[root@pi wiringPi 12\/04 05:38:22]# gpio -v\ngpio version: 2.31\nCopyright (c) 2012-2015 Gordon Henderson\nThis is free software with ABSOLUTELY NO WARRANTY.\nFor details type: gpio -warranty\n\nRaspberry Pi Details:\n  Type: Pi 2, Revision: 01, Memory: 1024MB, Maker: Embest \n  Device tree is enabled.\n  * Root or sudo required for GPIO access.\n[root@pi wiringPi 12\/04 05:38:41]# <\/pre>\n

\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n

[root@pi wiringPi 12\/04 05:38:45]# gpio -v\ngpio version: 2.31\nCopyright (c) 2012-2015 Gordon Henderson\nThis is free software with ABSOLUTELY NO WARRANTY.\nFor details type: gpio -warranty\n\nRaspberry Pi Details:\n  Type: Pi 2, Revision: 01, Memory: 1024MB, Maker: Embest \n  Device tree is enabled.\n  * Root or sudo required for GPIO access.\n[root@pi wiringPi 12\/04 05:38:46]# <\/pre>\n

\u3068\u3044\u3046\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002Gordon Henderson\u3055\u3093\u304c\u4f5c\u3089\u308c\u3066\u305f\u3088\u3046\u3067\u3059\u3002\u611f\u8b1d\u3002<\/p>\n

[root@pi work 12\/04 06:17:08]# gpio -warranty\ngpio version: 2.31\nCopyright (c) 2012-2015 Gordon Henderson\n\n    This program is free software; you can redistribute it and\/or modify\n    it under the terms of the GNU Leser General Public License as published\n    by the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public License\n    along with this program. If not, see <http:\/\/www.gnu.org\/licenses\/>.\n\n[root@pi work 12\/04 06:17:14]# <\/pre>\n

\u3068\u308a\u3042\u3048\u305a\u3001\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n

\"a\" <\/p>\n

\u3044\u3064\u3082PIN\u756a\u53f7\u3092\u5fd8\u308c\u3066\u691c\u7d22\u3057\u307e\u3059\u3002\u8cbc\u308a\u4ed8\u3051\u3066\u304a\u304f\u3053\u3068\u306b\u3002\u30e9\u30ba\u30d1\u30a4\u306e\u30d4\u30f3\u3002<\/p>\n

\"Raspberry-Pi-GPIO-compressed\" <\/p>\n

\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u3002<\/p>\n

\/\/ Include header file\n#include <wiringPi.h>\n\n\/\/ Define GPIO21 number\n#define LED 21\n\n\/\/ Main function\nint main(void) {\n        int i;\n\n        \/\/ Initialize WiringPi\n        if(wiringPiSetupGpio() == -1) return 1;\n\n        \/\/ Set GPIO pin to output mode\n        pinMode(LED, OUTPUT);\n\n        \/\/ Repeat LED blinking 10 times\n        for(i=0; i<100; i++){\n                digitalWrite(LED, 0);\n                delay(100);\n                digitalWrite(LED, 1);\n                delay(100);\n        }\n\n        \/\/ Turn off LED\n        digitalWrite(LED, 0);\n\n        return 0;\n}<\/pre>\n

\u30b3\u30f3\u30d1\u30a4\u30eb\u3001\u5b9f\u884c\u3002<\/p>\n

[pi@pi work]$ gcc -o blink blink.c -lwiringPi\n[pi@pi work]$ sudo .\/blink<\/pre>\n

\u7d42\u4e86\u3059\u308b\u3068\u3001\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u623b\u308a\u307e\u3059\u3002RasPi \u306eGPIO\u306f\u305f\u304f\u3055\u3093\u3042\u308b\u306e\u3067\u3001\u540c\u6642\u306b\u3044\u304f\u3064\u4f7f\u3048\u308b\u3093\u3067\u3057\u3087\u3046\u306d\u3002<\/p>\n

 <\/p>\n

\u30b7\u30d5\u30c8\u30ec\u30b8\u30b9\u30bf\u30fc\u3092\u7d4c\u7531\u3057\u306a\u304f\u3066\u3082\u3001\u4eca\u56de\u300115\u672c\u306eGPIO\u3092\u4f7f\u3048\u308c\u3070\u3088\u3055\u305d\u3046\u3067\u3059\u304c\u3001<\/p>\n

[root@pi work 12\/04 06:26:32]# gpio readall\n +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |\n +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |\n |   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5V      |     |     |\n |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |\n |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |\n |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |\n |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |\n |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |\n |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |\n |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |\n |  10 |  12 |    MOSI | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |\n |   9 |  13 |    MISO | ALT0 | 0 | 21 || 22 | 0 | OUT  | GPIO. 6 | 6   | 25  |\n |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | ALT0 | CE0     | 10  | 8   |\n |     |     |      0v |      |   | 25 || 26 | 1 | ALT0 | CE1     | 11  | 7   |\n |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |\n |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |\n |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |\n |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |\n |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |\n |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |\n |     |     |      0v |      |   | 39 || 40 | 0 | OUT  | GPIO.29 | 29  | 21  |\n +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+\n | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |\n +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+\n[root@pi work 12\/04 06:26:33]# <\/pre>\n

\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u306ewPi \u3068\u3044\u3046\u306e\u304c\u30a2\u30b5\u30a4\u30f3\u3055\u308c\u3066\u3044\u308b\u756a\u53f7\u3067\u3059\u304b\u306d\u3002<\/p>\n

\u30de\u30cb\u30e5\u30a2\u30eb\u3060\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u3067\u3059\u30021 \u3067ON\uff08\u70b9\u706f\uff09 0\u3067OFF\uff08\u6d88\u706f\uff09<\/p>\n

[root@pi work 12\/04 06:32:40]# gpio -g write 21 1 \n[root@pi work 12\/04 06:33:56]# gpio -g write 21 0<\/pre>\n

\u3068\u308a\u3042\u3048\u305a\u3001\u4f7f\u3048\u305d\u3046\u3067\u3059\u306d\u3002\u3042\u3068\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u554f\u984c\u3068\u306a\u308a\u307e\u3059\u3002\u3055\u3041\u3066\u3001\u672c\u65e5\u91d1\u66dc\u65e5\u3002\u304a\u4ed5\u4e8b\u7d42\u308f\u308c\u3070\u307e\u305f\u958b\u767a\u30bf\u30a4\u30e0\u3067\u3059\u3002<\/p>\n

examples \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u53c2\u8003\u30b3\u30fc\u30c9\u304c\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059\u3002<\/p>\n

[root@pi examples 12\/04 06:41:26]# pwd\n\/home\/pi\/wiringPi\/examples\n[root@pi examples 12\/04 06:41:28]# \n[root@pi examples 12\/04 06:41:29]# tree\n.\n\u251c\u2500\u2500 blink12.c\n\u251c\u2500\u2500 blink12drcs.c\n\u251c\u2500\u2500 blink6drcs.c\n\u251c\u2500\u2500 blink8.c\n\u251c\u2500\u2500 blink.c\n\u251c\u2500\u2500 blink.rtb\n\u251c\u2500\u2500 blink.sh\n\u251c\u2500\u2500 clock.c\n\u251c\u2500\u2500 COPYING.LESSER\n\u251c\u2500\u2500 delayTest.c\n\u251c\u2500\u2500 ds1302.c\n\u251c\u2500\u2500 Gertboard\n\u2502   \u251c\u2500\u2500 7segments.c\n\u2502   \u251c\u2500\u2500 buttons.c\n\u2502   \u251c\u2500\u2500 gertboard.c\n\u2502   \u251c\u2500\u2500 Makefile\n\u2502   \u251c\u2500\u2500 record.c\n\u2502   \u251c\u2500\u2500 temperature.c\n\u2502   \u251c\u2500\u2500 voltmeter.c\n\u2502   \u2514\u2500\u2500 vumeter.c\n\u251c\u2500\u2500 header.h\n\u251c\u2500\u2500 isr.c\n\u251c\u2500\u2500 isr-osc.c\n\u251c\u2500\u2500 lcd-adafruit.c\n\u251c\u2500\u2500 lcd.c\n\u251c\u2500\u2500 lowPower.c\n\u251c\u2500\u2500 Makefile\n\u251c\u2500\u2500 max31855.c\n\u251c\u2500\u2500 nes.c\n\u251c\u2500\u2500 okLed.c\n\u251c\u2500\u2500 PiFace\n\u2502   \u251c\u2500\u2500 blink.c\n\u2502   \u251c\u2500\u2500 buttons.c\n\u2502   \u251c\u2500\u2500 ladder.c\n\u2502   \u251c\u2500\u2500 Makefile\n\u2502   \u251c\u2500\u2500 metro.c\n\u2502   \u251c\u2500\u2500 motor.c\n\u2502   \u2514\u2500\u2500 reaction.c\n\u251c\u2500\u2500 PiGlow\n\u2502   \u251c\u2500\u2500 Makefile\n\u2502   \u251c\u2500\u2500 piGlow0.c\n\u2502   \u251c\u2500\u2500 piGlow1.c\n\u2502   \u2514\u2500\u2500 piglow.c\n\u251c\u2500\u2500 pwm.c\n\u251c\u2500\u2500 q2w\n\u2502   \u251c\u2500\u2500 binary.c\n\u2502   \u251c\u2500\u2500 blink.c\n\u2502   \u251c\u2500\u2500 blink-io.c\n\u2502   \u251c\u2500\u2500 blink.sh\n\u2502   \u251c\u2500\u2500 bright.c\n\u2502   \u251c\u2500\u2500 button.c\n\u2502   \u251c\u2500\u2500 Makefile\n\u2502   \u2514\u2500\u2500 volts.c\n\u251c\u2500\u2500 README.TXT\n\u251c\u2500\u2500 rht03.c\n\u251c\u2500\u2500 serialRead.c\n\u251c\u2500\u2500 serialTest.c\n\u251c\u2500\u2500 servo.c\n\u251c\u2500\u2500 softPwm.c\n\u251c\u2500\u2500 softTone.c\n\u251c\u2500\u2500 speed.c\n\u251c\u2500\u2500 spiSpeed.c\n\u2514\u2500\u2500 wfi.c\n\n4 directories, 59 files\n[root@pi examples 12\/04 06:41:32]# <\/pre>\n

 <\/p>\n

\u30b3\u30cf\u30af\u30e9\u30d5\u30c8\u3055\u3093\u304b\u3089\u3082\u767a\u9001\u3055\u308c\u305f\u3088\u3046\u3067\u3001\u571f\u65e5\u306b\u306f\u306a\u3093\u3089\u304b\u697d\u3057\u3081\u305d\u3046\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u3068\u308a\u3042\u3048\u305a\u3001RasPi \u3067C \u3092\u691c\u7d22\u3057\u305f\u3089\u4e00\u756a\u6700\u521d\u306b\u30d2\u30c3\u30c8\u3057\u305f\u306e\u3067\u3001\u3053\u308c\u3067\u3002 \u30aa\u30d5\u30a3\u30b7\u30e3\u30eb http:\/\/wiringpi.com\/ GITHUB https:\/\/github.com\/WiringPi Ruby \u3084 P […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","footnotes":""},"categories":[31,69],"tags":[],"acf":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"JunkHack","author_link":"https:\/\/hack.gpl.jp\/author\/junkhack\/"},"uagb_comment_info":1,"uagb_excerpt":"\u3068\u308a\u3042\u3048\u305a\u3001RasPi \u3067C \u3092\u691c\u7d22\u3057\u305f\u3089\u4e00\u756a\u6700\u521d\u306b\u30d2\u30c3\u30c8\u3057\u305f\u306e\u3067\u3001\u3053\u308c\u3067\u3002 \u30aa\u30d5\u30a3\u30b7\u30e3\u30eb http:\/\/wi…","_links":{"self":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts\/1811"}],"collection":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/comments?post=1811"}],"version-history":[{"count":0,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts\/1811\/revisions"}],"wp:attachment":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/media?parent=1811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/categories?post=1811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/tags?post=1811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}