{"id":3099,"date":"2023-03-03T18:39:32","date_gmt":"2023-03-03T09:39:32","guid":{"rendered":"https:\/\/okamoto3.com\/?p=3099"},"modified":"2023-03-24T11:08:27","modified_gmt":"2023-03-24T02:08:27","slug":"chatgpt-ir-led-python","status":"publish","type":"post","link":"https:\/\/okamoto3.com\/index.php\/2023\/03\/03\/chatgpt-ir-led-python\/3099\/","title":{"rendered":"ChatGPT\u3055\u307e\u3001raspberry pi os\u3067gpio0\u306b\u63a5\u7d9a\u3057\u305f\u8d64\u5916\u7ddaLED\u309238Khz\u3067\u5909\u8abf\u3057\u3066SONY\u306e\u30c6\u30ec\u30d3\u306e\u96fb\u6e90\u3092\u30aa\u30f3\u306b\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092python\u3067\u6559\u3048\u3066\u4e0b\u3055\u3044\u3002"},"content":{"rendered":"<h2 class=\"wp-block-heading\">\u304a\u7b54\u3048(1)<\/h2><p>Raspberry Pi OS\u3067\u8d64\u5916\u7ddaLED\u309238KHz\u3067\u5909\u8abf\u3057\u3066\u3001SONY\u306e\u30c6\u30ec\u30d3\u306e\u96fb\u6e90\u3092\u30aa\u30f3\u306b\u3059\u308b\u305f\u3081\u306b\u306f\u3001LIRC (Linux Infrared Remote Control) \u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3059\u308b\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002\u4ee5\u4e0b\u306f\u3001LIRC\u3092\u4f7f\u7528\u3057\u305fPython\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u4f8b\u3067\u3059\u3002<\/p><p>\u307e\u305a\u3001LIRC\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p><pre class=\"wp-block-preformatted\"><code class=\"!whitespace-pre hljs language-bash\">sudo apt-get install lirc<\/code><br><\/pre><p>\u6b21\u306b\u3001LIRC\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002 <code>\/etc\/lirc\/lirc_options.conf<\/code> \u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p><pre class=\"wp-block-preformatted\"><code class=\"!whitespace-pre hljs language-bash\">driver          = default<\/code><br><code class=\"!whitespace-pre hljs language-bash\">device          = \/dev\/lirc0<\/code><br><\/pre><p>\u6b21\u306b\u3001LIRC\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002 <code>\/etc\/lirc\/lircd.conf<\/code> \u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p><pre class=\"wp-block-preformatted\"><code class=\"!whitespace-pre hljs language-yaml\">begin remote<\/code><br><br><code class=\"!whitespace-pre hljs language-yaml\">  name  SONY_TV<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  flags RAW_CODES|CONST_LENGTH<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  eps            30<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  aeps          100<\/code><br><br><code class=\"!whitespace-pre hljs language-yaml\">  header       8955  4449<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  one           575  1664<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  zero          575   532<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  ptrail        575<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  repeat       8994  4450<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  pre_data_bits   16<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  pre_data       0x20DF<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  gap          107977<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">  toggle_bit_mask 0x0<\/code><br><br><code class=\"!whitespace-pre hljs language-yaml\">      begin raw_codes<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">          name POWER<\/code><br><code class=\"!whitespace-pre hljs language-yaml\">          244 139 24 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23 144 23<\/code><br><\/pre><h2 class=\"wp-block-heading\">\u3042\u308c\uff1f\u3053\u3053\u3067\u7d42\u308f\u308a\uff1f<\/h2><p>2\u56de\u305f\u305a\u306d\u3066\u3082\u540c\u3058\u3002\u805e\u304d\u65b9\u3092\u5909\u3048\u3066\u3001\u3082\u3046\u4e00\u5ea6\u6559\u3048\u3066\u3082\u3089\u3046\u3002<\/p><p>raspberry pi os \u3067\u3001gpio0\u306b\u63a5\u7d9a\u3057\u305f\u8d64\u5916\u7ddaLED\u309238Khz\u3067\u5909\u8abf\u3057\u3066\u3001SONY\u306e\u30c6\u30ec\u30d3\u306e\u96fb\u6e90\u3092\u30aa\u30f3\u306b\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092python\u3067\u6559\u3048\u3066\u4e0b\u3055\u3044\u3002\u306a\u304a\u3001<strong><mark style=\"background-color:rgba(0,0,0,0);color:#cf2e2e\" class=\"has-inline-color has-vivid-red-color\">LIRC\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u7d42\u308f\u3063\u3066\u3044\u307e\u3059\u3002<\/mark><\/strong><\/p><h2 class=\"wp-block-heading\">\u304a\u7b54\u3048(2)<\/h2><p>LIRC\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u305f\u72b6\u614b\u3067\u3001GPIO\u30d4\u30f3\u3092\u4f7f\u7528\u3057\u306638KHz\u306e\u8d64\u5916\u7dda\u4fe1\u53f7\u3092\u9001\u4fe1\u3059\u308bPython\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001GPIO 0\u30d4\u30f3\u306b\u63a5\u7d9a\u3055\u308c\u305f\u8d64\u5916\u7ddaLED\u3092\u4f7f\u7528\u3057\u3066\u3001SONY\u30c6\u30ec\u30d3\u306e\u96fb\u6e90\u3092\u30aa\u30f3\u306b\u3059\u308bPython\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u4f8b\u3067\u3059\u3002<\/p><pre class=\"wp-block-preformatted\"><code class=\"!whitespace-pre hljs language-python\">import time<\/code><br><code class=\"!whitespace-pre hljs language-python\">import lirc<\/code><br><code class=\"!whitespace-pre hljs language-python\">import RPi.GPIO as GPIO<\/code><br><br><code class=\"!whitespace-pre hljs language-python\"># LIRC\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u540d<\/code><br><code class=\"!whitespace-pre hljs language-python\">LIRC_CONF = \"SONY_TV\"<\/code><br><br><code class=\"!whitespace-pre hljs language-python\"># GPIO\u30d4\u30f3\u756a\u53f7<\/code><br><code class=\"!whitespace-pre hljs language-python\">GPIO_PIN = 0<\/code><br><br><code class=\"!whitespace-pre hljs language-python\"># GPIO\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7<\/code><br><code class=\"!whitespace-pre hljs language-python\">GPIO.setmode(GPIO.BCM)<\/code><br><code class=\"!whitespace-pre hljs language-python\">GPIO.setup(GPIO_PIN, GPIO.OUT)<\/code><br><br><code class=\"!whitespace-pre hljs language-python\"># LIRC\u521d\u671f\u5316<\/code><br><code class=\"!whitespace-pre hljs language-python\">lirc.init(LIRC_CONF)<\/code><br><br><code class=\"!whitespace-pre hljs language-python\"># \u9001\u4fe1\u95a2\u6570<\/code><br><code class=\"!whitespace-pre hljs language-python\">def send_ir(remote, key):<\/code><br><code class=\"!whitespace-pre hljs language-python\">    code = lirc.get_code(remote, key)<\/code><br><code class=\"!whitespace-pre hljs language-python\">    if code:<\/code><br><code class=\"!whitespace-pre hljs language-python\">        code = [int(i) for i in code.split()]<\/code><br><code class=\"!whitespace-pre hljs language-python\">        for i in range(len(code)):<\/code><br><code class=\"!whitespace-pre hljs language-python\">            # 38KHz\u3067\u5909\u8abf\u3057\u3066\u9001\u4fe1<\/code><br><code class=\"!whitespace-pre hljs language-python\">            if i % 2 == 0:<\/code><br><code class=\"!whitespace-pre hljs language-python\">                GPIO.output(GPIO_PIN, GPIO.HIGH)<\/code><br><code class=\"!whitespace-pre hljs language-python\">                time.sleep(code[i] \/ 1000000.0)<\/code><br><code class=\"!whitespace-pre hljs language-python\">            else:<\/code><br><code class=\"!whitespace-pre hljs language-python\">                GPIO.output(GPIO_PIN, GPIO.LOW)<\/code><br><code class=\"!whitespace-pre hljs language-python\">                time.sleep(code[i] \/ 1000000.0)<\/code><br><br><code class=\"!whitespace-pre hljs language-python\"># \u96fb\u6e90\u30aa\u30f3\u3092\u9001\u4fe1<\/code><br><code class=\"!whitespace-pre hljs language-python\">send_ir(\"SONY_TV\", \"POWER\")<\/code><br><br><code class=\"!whitespace-pre hljs language-python\"># \u7d42\u4e86\u51e6\u7406<\/code><br><code class=\"!whitespace-pre hljs language-python\">GPIO.cleanup()<\/code><br><code class=\"!whitespace-pre hljs language-python\">lirc.deinit()<\/code><br><\/pre><p>\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u306f\u3001LIRC\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u540d\u3001GPIO\u30d4\u30f3\u756a\u53f7\u3001\u304a\u3088\u3073\u9001\u4fe1\u3059\u308bIR\u30ea\u30e2\u30fc\u30c8\u30ad\u30fc\u540d\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u307e\u305f\u3001<code>send_ir<\/code>\u95a2\u6570\u3067\u8d64\u5916\u7dda\u4fe1\u53f7\u309238KHz\u3067\u5909\u8abf\u3057\u3066\u9001\u4fe1\u3057\u3066\u3044\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001<code>GPIO.cleanup()<\/code>\u304a\u3088\u3073<code>lirc.deinit()<\/code>\u3092\u547c\u3073\u51fa\u3057\u3066\u3001GPIO\u30d4\u30f3\u3068LIRC\u3092\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3057\u307e\u3059\u3002<\/p><p><a href=\"https:\/\/help.openai.com\/en\/articles\/6825453-chatgpt-release-notes\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"underline\">ChatGPT Feb 13 Version<\/a>. Free Research Preview. Our goal is to make AI systems more natural and safe to interact with. Your feedback will help us improve.<\/p><figure class=\"wp-block-embed is-type-wp-embed is-provider-sgg-039-s wp-block-embed-sgg-039-s\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"97B6uvvXXa\"><a href=\"https:\/\/okamoto3.com\/index.php\/2023\/03\/04\/chatgpt-lircd\/3109\/\">ChatGPT\u3055\u307e\u3001Raspberry Pi\u306eLIRC\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u30ea\u30e2\u30b3\u30f3\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u8fbc\u3080\u65b9\u6cd5\u3092\u6559\u3048\u3066\u4e0b\u3055\u3044\u3002<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;ChatGPT\u3055\u307e\u3001Raspberry Pi\u306eLIRC\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u30ea\u30e2\u30b3\u30f3\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u8fbc\u3080\u65b9\u6cd5\u3092\u6559\u3048\u3066\u4e0b\u3055\u3044\u3002&#8221; &#8212; sGG&#039;s\" src=\"https:\/\/okamoto3.com\/index.php\/2023\/03\/04\/chatgpt-lircd\/3109\/embed\/#?secret=Si5aSvAebj#?secret=97B6uvvXXa\" data-secret=\"97B6uvvXXa\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure><h2 class=\"wp-block-heading\">\u7591\u554f<\/h2><ul class=\"wp-block-list\"><li>\u8457\u4f5c\u6a29\uff1f\u308f\u3057\u306f\u9055\u53cd\u3067\u3059\u304b\uff1f<\/li><\/ul><p>\u305d\u308c\u306b\u3057\u3066\u3082\u51c4\u3044\uff01\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002<\/p><p class=\"has-text-align-left\">\u4ee5\u4e0a<\/p><hr class=\"wp-block-separator has-css-opacity\"\/><div class=\"wp-block-image is-style-rounded\"><figure class=\"aligncenter size-thumbnail\"><a href=\"https:\/\/youtube.com\/user\/hishigeki3\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/10\/Screenshot_2021-10-25-07-00-51-667_com.google.android.youtube-01_copy_270x246.jpeg?resize=150%2C150&#038;ssl=1\" alt=\"\" class=\"wp-image-658\" srcset=\"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/10\/Screenshot_2021-10-25-07-00-51-667_com.google.android.youtube-01_copy_270x246.jpeg?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/10\/Screenshot_2021-10-25-07-00-51-667_com.google.android.youtube-01_copy_270x246.jpeg?resize=100%2C100&amp;ssl=1 100w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><figcaption class=\"wp-element-caption\">\u3088\u308d\u3057\u3051\u308c\u3070\u30c1\u30e3\u30f3\u30cd\u30eb\u767b\u9332\u3088\u308d\u3057\u304f\u304a\u9858\u3044\u7533\u3057\u4e0a\u3052\u307e\u3059\uff01<\/figcaption><\/figure><\/div><hr class=\"wp-block-separator has-css-opacity\"\/>","protected":false},"excerpt":{"rendered":"<p>\u304a\u7b54\u3048(1) Raspberry Pi OS\u3067\u8d64\u5916\u7ddaLED\u309238KHz\u3067\u5909\u8abf\u3057\u3066\u3001SONY\u306e\u30c6\u30ec\u30d3\u306e\u96fb\u6e90\u3092\u30aa\u30f3\u306b\u3059\u308b\u305f\u3081\u306b\u306f\u3001LIRC (Linux Infrared Remote Control) \u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3059\u308b&hellip; <a class=\"more-link\" href=\"https:\/\/okamoto3.com\/index.php\/2023\/03\/03\/chatgpt-ir-led-python\/3099\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">ChatGPT\u3055\u307e\u3001raspberry pi os\u3067gpio0\u306b\u63a5\u7d9a\u3057\u305f\u8d64\u5916\u7ddaLED\u309238Khz\u3067\u5909\u8abf\u3057\u3066SONY\u306e\u30c6\u30ec\u30d3\u306e\u96fb\u6e90\u3092\u30aa\u30f3\u306b\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092python\u3067\u6559\u3048\u3066\u4e0b\u3055\u3044\u3002<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3100,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[220,23,18,213],"tags":[136],"class_list":["post-3099","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chatgpt","category-raspberry-pi","category-repair","category-all-articles","tag-python","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2023\/03\/IMG_20230303_184329.jpg?fit=433%2C216&ssl=1","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/posts\/3099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/comments?post=3099"}],"version-history":[{"count":4,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/posts\/3099\/revisions"}],"predecessor-version":[{"id":3140,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/posts\/3099\/revisions\/3140"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/media\/3100"}],"wp:attachment":[{"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/media?parent=3099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/categories?post=3099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/tags?post=3099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}