{"id":1741,"date":"2017-12-23T12:52:12","date_gmt":"2017-12-23T03:52:12","guid":{"rendered":"http:\/\/bezelie.com\/blog\/?page_id=1741"},"modified":"2018-02-25T13:15:46","modified_gmt":"2018-02-25T04:15:46","slug":"be-12%ef%bc%9a%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b","status":"publish","type":"page","link":"http:\/\/bezelie.com\/blog\/?page_id=1741","title":{"rendered":"\u30b9\u30a4\u30c3\u30c1\u3067\u5165\u529b\u3057\u3066\u307f\u308b"},"content":{"rendered":"<h2>sample_input1.py<\/h2>\n<h5>\u6a5f\u80fd<\/h5>\n<p style=\"padding-left: 30px;\">\u30fb\u30b9\u30a4\u30c3\u30c1\u5165\u529b\u3002<\/p>\n<h5>\u4e8b\u524d\u6e96\u5099<\/h5>\n<p style=\"padding-left: 30px;\">\u30fb\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1\u3068\u62b5\u6297\uff0810k\u03a9\uff09\u3092\u30e9\u30ba\u30d1\u30a4\u306eGPIO24\u3068GND\u306b\u3064\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/sample_input1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2239\" src=\"http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/sample_input1-300x239.jpg\" alt=\"\" width=\"300\" height=\"239\" srcset=\"http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/sample_input1-300x239.jpg 300w, http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/sample_input1.jpg 495w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/2018-02-18-16.15.05w800.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2232\" src=\"http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/2018-02-18-16.15.05w800-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/2018-02-18-16.15.05w800-300x225.jpg 300w, http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/2018-02-18-16.15.05w800-768x576.jpg 768w, http:\/\/bezelie.com\/blog\/wp-content\/uploads\/2018\/02\/2018-02-18-16.15.05w800.jpg 800w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><\/p>\n<h5>\u5b9f\u884c\u65b9\u6cd5<\/h5>\n<pre class=\"lang:sh decode:true\">python sample_input1.py<\/pre>\n<p style=\"text-align: center;\"><iframe loading=\"lazy\" width=\"560\" height=\"314\" src=\"\/\/www.youtube.com\/embed\/UoF00HYpeQA\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\" data-mce-fragment=\"1\"><\/iframe><\/p>\n<h5>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h5>\n<pre class=\"\">#!\/usr\/bin\/python\n# -*- coding: utf-8 -*- : \u6587\u5b57\u30b3\u30fc\u30c9\u306e\u6307\u5b9a\n# Bezelie Sample Code for Raspberry Pi : \u30b9\u30a4\u30c3\u30c1\uff08\uff0b\u30d7\u30eb\u30c0\u30a6\u30f3\u62b5\u6297\uff09\u5165\u529b\u306e\u30b5\u30f3\u30d7\u30eb\n# \u30de\u30cb\u30e5\u30a2\u30eb\u3092\u898b\u3066\u30e9\u30ba\u30d1\u30a4\u306b\u30b9\u30a4\u30c3\u30c1\u3092\u63a5\u7d9a\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u8aad\u307f\u8fbc\u307f\nfrom time import sleep # sleep(\u30a6\u30a7\u30a4\u30c8\u51e6\u7406)\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u8aad\u307f\u8fbc\u307f\nimport RPi.GPIO as GPIO # GPIO(\u6c4e\u7528\u5165\u51fa\u529b\u7aef\u5b50)\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u8aad\u307f\u8fbc\u307f\n\n# \u521d\u671f\u8a2d\u5b9a\nGPIO.setmode(GPIO.BCM) # GPIO\u3092GPIO\u756a\u53f7\u3067\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\nGPIO.setup(24, GPIO.IN) # GPIO\u306e24\u30d4\u30f3\u3092\u5165\u529b\u30e2\u30fc\u30c9\u306b\u8a2d\u5b9a\n\n# \u95a2\u6570\ndef main():\n try:\n   print \"\u958b\u59cb\u3057\u307e\u3059\"\n   while True: # \u7e70\u308a\u8fd4\u3057\u51e6\u7406\n     if GPIO.input(24)==GPIO.HIGH: # GPIO24\u306b3.3V\u306e\u96fb\u5727\u304c\u304b\u304b\u3063\u3066\u3044\u305f\u3089\u30fb\u30fb\u30fb\n       print \"\u30b9\u30a4\u30c3\u30c1\u304c\u62bc\u3055\u308c\u3066\u3044\u307e\u3059\"\n     else: # \u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306f\u30fb\u30fb\u30fb\n       print \"\u30b9\u30a4\u30c3\u30c1\u306f\u62bc\u3055\u308c\u3066\u307e\u305b\u3093\"\n     sleep (0.5) # 0.5\u79d2\u5f85\u3064\n except KeyboardInterrupt: # \u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\uff0bC\u304c\u62bc\u3055\u308c\u305f\u5834\u5408\u306e\u51e6\u7406\n   print \"\u7d42\u4e86\u3057\u307e\u3057\u305f\"\n   GPIO.cleanup() # \u30dd\u30fc\u30c8\u3092\u30af\u30ea\u30a2\n\n# \u76f4\u63a5\u5b9f\u884c\u3055\u308c\u305f\u5834\u5408\u306e\u51e6\u7406\nif __name__ == \"__main__\":\n main()<\/pre>\n<h5>\u89e3\u8aac<\/h5>\n<p style=\"padding-left: 30px;\">\u30fb\u96fb\u6e90pin\u3068GNDpin\u306b\u8fd1\u3044\u306e\u3067GPIO24\u3092\u4f7f\u3044\u307e\u3057\u305f\u304c\u3001\u4ed6\u306eGPIO\u3067\u3082\u69cb\u3044\u307e\u305b\u3093\u3002<br \/>\n\u30fb\uff12\uff16\u884c\u76ee\u306e\u300cGPIO.cleanup()\u300d\u3092\u5b9f\u884c\u305b\u305a\u306b\u7d42\u4e86\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067GPIO24\u3092\u4f7f\u304a\u3046\u3068\u3057\u305f\u3068\u304d\u3001\u3059\u3067\u306b\u4f7f\u7528\u4e2d\u3060\u3068\u8a8d\u8b58\u3055\u308c\u3066\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<h5>\u5fdc\u7528<\/h5>\n<p style=\"padding-left: 30px;\">\u30fb\u30aa\u30f3\u3084\u30aa\u30d5\u306e\u3042\u3068\u306b\u3042\u308b\u300csleep(1)\u300d\u306e\u300c\uff11\u300d\u3092\u3001\u300co.5\u300d\u306a\u3069\u3082\u3063\u3068\u5c0f\u3055\u306a\u5024\u306b\u5909\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002LED\u304c\u901f\u304f\u70b9\u6ec5\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sample_input1.py \u6a5f\u80fd \u30fb\u30b9\u30a4\u30c3\u30c1\u5165\u529b\u3002 \u4e8b\u524d\u6e96\u5099 \u30fb\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1\u3068\u62b5\u6297\uff0810k\u03a9\uff09\u3092\u30e9\u30ba\u30d1\u30a4\u306eGPIO24\u3068GND\u306b\u3064\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002 \u5b9f\u884c\u65b9\u6cd5 python sample_input1.py \u30bd\u30fc\u30b9 &hellip; <a href=\"http:\/\/bezelie.com\/blog\/?page_id=1741\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u30b9\u30a4\u30c3\u30c1\u3067\u5165\u529b\u3057\u3066\u307f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1375,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1741","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=\/wp\/v2\/pages\/1741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1741"}],"version-history":[{"count":16,"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=\/wp\/v2\/pages\/1741\/revisions"}],"predecessor-version":[{"id":2322,"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=\/wp\/v2\/pages\/1741\/revisions\/2322"}],"up":[{"embeddable":true,"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=\/wp\/v2\/pages\/1375"}],"wp:attachment":[{"href":"http:\/\/bezelie.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}