{"id":474,"date":"2014-07-24T10:00:42","date_gmt":"2014-07-24T01:00:42","guid":{"rendered":"http:\/\/www.skyarch.net\/blog\/?p=474"},"modified":"2025-09-08T13:57:40","modified_gmt":"2025-09-08T04:57:40","slug":"raspberry-pi%e3%81%a7%e3%83%91%e3%83%88%e3%83%a9%e3%83%b3%e3%83%97%e3%82%92%e4%bd%9c%e6%88%90%e2%91%a1","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/raspberry-pi%e3%81%a7%e3%83%91%e3%83%88%e3%83%a9%e3%83%b3%e3%83%97%e3%82%92%e4%bd%9c%e6%88%90%e2%91%a1\/","title":{"rendered":"Raspberry Pi\u3067\u30d1\u30c8\u30e9\u30f3\u30d7\u3092\u4f5c\u6210\u2461"},"content":{"rendered":"<p>\u904e\u53bb\u306e\u8a18\u4e8b\u306f\u4e0b\u8a18\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/www.skyarch.net\/blog\/?p=444\">Raspberry Pi\u3067\u30d1\u30c8\u30e9\u30f3\u30d7\u3092\u4f5c\u6210\u2460 \u6982\u8981<\/a><\/p>\n<p>\u3053\u308c\u304b\u30895\u56de\u306b\u6e21\u3063\u3066\u3001\u4e0b\u8a18\u6c42\u3081\u308b\u4ed5\u69d8\u306e\u90e8\u5206\u3092\u3069\u306e\u3088\u3046\u306b\u5b9f\u73fe\u3057\u305f\u304b\u8a18\u8f09\u3057\u3066\u884c\u304d\u307e\u3059\u3002<\/p>\n<h2>\u6c42\u3081\u308b\u4ed5\u69d8<\/h2>\n<ul>\n<li><a href=\"http:\/\/www.skyarch.net\/blog\/?p=474\">\u30a2\u30e9\u30fc\u30c8\u3092\u97f3\u3068\u5149\u3067\u4f1d\u3048\u3066\u304f\u308c\u308b<\/a> &lt;- \u4eca\u56de\u306f\u3053\u3061\u3089<\/li>\n<li><a href=\"http:\/\/www.skyarch.net\/blog\/?p=480\">snmptrap\u3092\u53d7\u4fe1<\/a><\/li>\n<li><a href=\"http:\/\/www.skyarch.net\/blog\/?p=514\">\u5b89\u5b9a\u7a3c\u50cd<\/a><\/li>\n<li><a href=\"http:\/\/www.skyarch.net\/blog\/?p=609\">\u81ea\u524d\u306e\u30b3\u30f3\u30d1\u30cd\u306b\u3066\u8a2d\u5b9a\u5909\u66f4\u304c\u53ef\u80fd<\/a><\/li>\n<\/ul>\n<h1>\u97f3\u306e\u90e8\u5206<\/h1>\n<p>\u4e0b\u8a18\u5199\u771f\u306b\u3042\u308b\u901a\u308a\u3001USB\u30b9\u30d4\u30fc\u30ab\u3092\u30e2\u30ce\u30e9\u30eb\u5316\u3057\u3066\u6d41\u7528\u3057\u3066\u304a\u308a\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/www2.elecom.co.jp\/multimedia\/speaker\/ms-w11u\/\"><a href=\"http:\/\/www2.elecom.co.jp\/multimedia\/speaker\/ms-w11u\/\">http:\/\/www2.elecom.co.jp\/multimedia\/speaker\/ms-w11u\/<\/a><\/a><\/p>\n<p>\u7d44\u307f\u8fbc\u307f\u7cfb\u3067\u306f\u3001\u96fb\u6d41\u304c\u3069\u308c\u4f4d\u6d41\u305b\u308b\u304b\u3001\u30b5\u30a6\u30f3\u30c9\u518d\u751f\u3067\u3042\u308c\u3070<br \/>\n\u30c7\u30b3\u30fc\u30c0\u7b49\u3092\u691c\u8a0e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001Raspberry Pi\u306fUSB\u30c7\u30d0\u30a4\u30b9\u3092\u305d\u306e\u307e\u307e\u3064\u306a\u3052\u308b\u306e\u3067<\/p>\n<p>\u3068\u3066\u3082\u697d\u3067\u3059\u3001\u4f46\u3057\u3042\u307e\u308a\u306b\u5927\u304d\u306a\u96fb\u6d41\u306e\u6d41\u308c\u308b\u7269\u306f<br \/>\n\u4fdd\u8b77\u56de\u8def\u306b\u3088\u308a\u5236\u9650\u3055\u308c\u308b\u305d\u3046\u306a\u306e\u3067\u3054\u6ce8\u610f\u4e0b\u3055\u3044\u3002<br \/>\n\u5236\u9650\u5024\u306f\u57fa\u677f\u306e\u30ea\u30d3\u30b8\u30e7\u30f3\u306b\u3088\u3063\u3066\u3082\u9055\u3044\u304c\u3042\u308b\u305d\u3046\u3067\u3059\u3002<\/p>\n<a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/IMG_1904.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/IMG_1904-225x300.jpg\" alt=\"IMG_1904\" width=\"225\" height=\"300\" class=\"aligncenter size-medium wp-image-449\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/IMG_1904-225x300.jpg 225w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/IMG_1904.jpg 240w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a>\n<h1>\u5149\u306e\u90e8\u5206<\/h1>\n<p>\u30b3\u30f3\u30bb\u30f3\u30c8\u306b\u633f\u3057\u591c\u306b\u306a\u308b\u3068\u5149\u3063\u3066\u304f\u308c\u308b\u30a4\u30f3\u30c6\u30ea\u30a2\u30e9\u30a4\u30c8\u3092\u4f7f\u3044\u307e\u3057\u305f<br \/>\n\u88cf\u306e\u30b3\u30f3\u30bb\u30f3\u30c8\u30d7\u30e9\u30b0\u3092\u5f15\u3063\u3053\u629c\u3044\u305f\u90e8\u5206\u3067\u30b1\u30fc\u30d6\u30eb\u53d6\u308a\u56de\u3057\u304c\u826f\u3044\u611f\u3058\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/P6281522.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/P6281522-300x225.jpg\" alt=\"P6281522\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-451\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/P6281522-300x225.jpg 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/P6281522.jpg 320w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Raspberry Pi GPIO\u306e\u96fb\u6d41\u5236\u9650\u306b\u5f15\u3063\u304b\u304b\u3089\u306a\u3044\u3088\u3046\u306b<br \/>\nIO\u30dd\u30fc\u30c8\u4e00\u3064\u306b\u4ed8\u304dLED\u30921\u500b\u99c6\u52d5\u3057\u307e\u3059\u3002\uff08\u8a082\u500b\uff09<\/p>\n<p>\u4e2d\u8eab\u306e\u57fa\u677f\u3092\u6d41\u7528\u3057\u305f\u304b\u3063\u305f\u305f\u3081\u8868\u9762\u5b9f\u88c5\u90e8\u54c1\u7b49\u306f\u5168\u3066\u53d6\u308a\u53bb\u308a<br \/>\nLED\u3092\u7121\u7406\u3084\u308a\u5b9f\u88c5\u306e\u4e0a\u3001\u30db\u30c3\u30c8\u30dc\u30f3\u30c9\u3067\u56fa\u5b9a\u3057\u307e\u3057\u305f\u3002<\/p>\n<a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/P6281520.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/P6281520-300x225.jpg\" alt=\"P6281520\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-450\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/P6281520-300x225.jpg 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/P6281520.jpg 320w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>\n<h1>\u30b5\u30a6\u30f3\u30c9\u3092\u518d\u751f\u3057LED\u3092\u70b9\u6ec5\u3055\u305b\u308b<\/h1>\n<p>\u6b21\u56de\u8a18\u8ff0\u3057\u307e\u3059\u304c snmptrapd \u3088\u308a\u4e0b\u8a18\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30ad\u30c3\u30af\u3059\u308b\u4e8b\u3067\u6319\u52d5\u3092\u5b9f\u73fe\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u5931\u6557\u8ac7<\/h2>\n<p>Python\u3067\u306eRaspberry Pi GPIO\u5236\u5fa1\u7528\u30e9\u30a4\u30d6\u30e9\u30ea\u8aad\u307f\u8fbc\u307f\u306b\u304a\u6c17\u3092\u3064\u3051\u4e0b\u3055\u3044\uff01<br \/>\n\u6c17\u3065\u304f\u306e\u306b\u4e381\u65e5\u639b\u304b\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u304c<br \/>\nRaspberry Pi \u306a\u306e\u3067 RPi &lt;- i\u3060\u3051\u5c0f\u6587\u5b57\u3067\u3057\u305f... orz<\/p>\n<pre>\n## \u8aa4\nimport RPI.GPIO as GPIO\n<\/pre>\n<pre>\n## \u6b63\nimport RPi.GPIO as GPIO\n<\/pre>\n<p>\u51e6\u7406\u306e\u4e2d\u5fc3\u90e8\u5206\u306e\u307f\u8a18\u8f09\u3057\u307e\u3057\u305f\u3001\u8a73\u7d30\u306fgithub\u3078\u3069\u3046\u305e<br \/>\n<a href=\"https:\/\/github.com\/tktk19\/Patlam-pi\/blob\/master\/bin\/trap_receive.py\"><a href=\"https:\/\/github.com\/tktk19\/Patlam-pi\/blob\/master\/bin\/trap_receive.py\">https:\/\/github.com\/tktk19\/Patlam-pi\/blob\/master\/bin\/trap_receive.py<\/a><\/a><\/p>\n<p><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nclass Alart():\ndef &lt;strong&gt;init&lt;\/strong&gt;(self):&lt;\/p&gt;\n&lt;h1&gt;GPIO\u306e\u8a2d\u5b9a&lt;\/h1&gt;\n&lt;pre&gt;&lt;code&gt;    GPIO.setwarnings(False)\n    GPIO.setmode(GPIO.BCM)\n    GPIO.setup(23, GPIO.OUT)\n    GPIO.setup(24, GPIO.OUT)\n\ndef __sound(self):\n    # \u30b5\u30a6\u30f3\u30c9\u518d\u751f\u30b3\u30de\u30f3\u30c9\u3092\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u5b9f\u884c\u3057\u307e\u3059\n    sound_file = os.path.join(patlam_pi.app.config&#x5B;'SOUNDDATA'], &amp;quot;ALARM.WAV&amp;quot;)\n    cmd = &amp;quot;\/usr\/bin\/aplay &amp;quot; + sound_file + &amp;quot; &amp;amp;&amp;quot;\n    os.system(cmd)\n\ndef __light(self):\n    __led_blink_count = patlam_pi.get_setting('LEDBlink')\n    i = 0\n    while i &amp;lt; int(__led_blink_count):\n        # LED2\u3064\u30920.5\u79d2\u9593\u9694\u3067UI\u8a2d\u5b9a\u56de\u6570\u5206\u70b9\u6ec5\u3055\u305b\u307e\u3059\n        GPIO.output(23, True)\n        GPIO.output(24, True)\n        time.sleep(0.5)\n        GPIO.output(23, False)\n        GPIO.output(24, False)\n        time.sleep(0.5)\n        i+=1\n\ndef fire(self):\n    self.__sound()\n    self.__light()&lt;\/code&gt;&lt;\/pre&gt;\n&lt;p&gt;if &lt;strong&gt;name&lt;\/strong&gt; == '&lt;strong&gt;main&lt;\/strong&gt;':\nalart = Alart()\nalart.fire()\n<\/pre>\n<\/p>\n<h2>\u30bd\u30fc\u30b9<\/h2>\n<p>\u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u53ca\u3073\u3001Raspberry Pi\u306e\u914d\u7dda\u56f3\u3001Raspbian\u3078\u5b9f\u65bd\u3057\u305f\u8a2d\u5b9a\u306f\u4e0b\u8a18\u3092\u53c2\u7167\u4e0b\u3055\u3044\u3002<br \/>\n<a href=\"https:\/\/github.com\/tktk19\/Patlam-pi\"><a href=\"https:\/\/github.com\/tktk19\/Patlam-pi\">https:\/\/github.com\/tktk19\/Patlam-pi<\/a><\/a><\/p>\n<h2>\u30e0\u30fc\u30d3\u30fc<\/h2>\n<p>8\/25\u66f4\u65b0\u30fb\u63b2\u8f09\u81f4\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/youtu.be\/vOGXVjvCQps\" target=\"_blank\">\u53c2\u8003\u52d5\u753b<\/a><\/p>\n<a href=\"http:\/\/www.raspberrypi.org\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/Raspi_Colour_R-207x250.png\" alt=\"Raspi_Colour_R-207x250\" width=\"207\" height=\"250\" class=\"aligncenter size-full wp-image-456\" \/><\/a>\n","protected":false},"excerpt":{"rendered":"<p>\u904e\u53bb\u306e\u8a18\u4e8b\u306f\u4e0b\u8a18\u3068\u306a\u308a\u307e\u3059\u3002 Raspberry Pi\u3067\u30d1\u30c8\u30e9\u30f3\u30d7\u3092\u4f5c\u6210\u2460 \u6982\u8981 \u3053\u308c\u304b\u30895\u56de\u306b\u6e21\u3063\u3066\u3001\u4e0b\u8a18\u6c42\u3081\u308b\u4ed5\u69d8\u306e\u90e8\u5206\u3092\u3069\u306e\u3088\u3046\u306b\u5b9f\u73fe\u3057\u305f\u304b\u8a18\u8f09\u3057\u3066\u884c\u304d\u307e\u3059\u3002 \u6c42\u3081\u308b\u4ed5\u69d8 \u30a2\u30e9\u30fc\u30c8\u3092\u97f3\u3068\u5149\u3067\u4f1d\u3048\u3066\u304f\u308c\u308b &lt;-&#8230;<\/p>\n","protected":false},"author":2,"featured_media":456,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"474","footnotes":""},"categories":[17,6,9],"tags":[65,105,56,40],"class_list":{"0":"post-474","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-raspberrypi","8":"category-monit","9":"category-dev","10":"tag-python","11":"tag-raspberrypi","12":"tag-56","13":"tag-40","14":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=474"}],"version-history":[{"count":15,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":29307,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/474\/revisions\/29307"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/456"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}