{"id":8677,"date":"2019-09-10T00:12:28","date_gmt":"2019-09-10T00:12:28","guid":{"rendered":"https:\/\/stevepedwards.today\/stevepedwards.com\/ElectronicsStuff\/?p=8677"},"modified":"2026-05-10T21:45:28","modified_gmt":"2026-05-10T20:45:28","slug":"reading-remote-control-codes-with-arduino","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/ElectronicsStuff\/reading-remote-control-codes-with-arduino\/","title":{"rendered":"Reading Remote Control Codes With Arduino"},"content":{"rendered":"<p>Old remotes can be re-purposed:<br \/>\n<iframe loading=\"lazy\" title=\"Repurposing an LED RF Remote to control &quot;anything&quot;!\" width=\"1778\" height=\"1000\" src=\"https:\/\/www.youtube.com\/embed\/pMc_H-REIJk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><br \/>\nFollowing this Post using the IR sensor connections - forget the LEDs just for reading codes:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-8680\" src=\"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-content\/uploads\/2019\/09\/IRcons-1024x645.png\" alt=\"\" width=\"840\" height=\"529\" srcset=\"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-content\/uploads\/2019\/09\/IRcons-1024x645.png 1024w, https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-content\/uploads\/2019\/09\/IRcons-300x189.png 300w, https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-content\/uploads\/2019\/09\/IRcons-768x484.png 768w, https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-content\/uploads\/2019\/09\/IRcons.png 1110w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/p>\n<pre class=\"lang:default decode:true \">#include &lt;IRremote.h&gt;\r\n#define first_key 48703\r\n#define second_key 58359\r\n#define third_key 539\r\n#define fourth_key 25979\r\nint receiver_pin = 8;\r\nint first_led_pin = 7;\r\nint second_led_pin = 6;\r\nint third_led_pin = 5;\r\nint fourth_led_pin = 4;\r\nint led[] = {0,0,0,0};\r\nIRrecv receiver(receiver_pin);\r\ndecode_results output;\r\nvoid setup()\r\n{\r\nSerial.begin(9600);\r\nreceiver.enableIRIn();\r\npinMode(first_led_pin, OUTPUT);\r\npinMode(second_led_pin, OUTPUT);\r\npinMode(third_led_pin, OUTPUT);\r\npinMode(fourth_led_pin, OUTPUT);\r\n}\r\nvoid loop() {\r\nif (receiver.decode(&amp;output)) {\r\nunsigned int value = output.value;\r\nswitch(value) {\r\ncase first_key:\r\nif(led[1] == 1) {\r\ndigitalWrite(first_led_pin, LOW);\r\nled[1] = 0;\r\n} else {\r\ndigitalWrite(first_led_pin, HIGH);\r\nled[1] = 1;\r\n}\r\nbreak;\r\ncase second_key:\r\nif(led[2] == 1) {\r\ndigitalWrite(second_led_pin, LOW);\r\nled[2] = 0;\r\n} else {\r\ndigitalWrite(second_led_pin, HIGH);\r\nled[2] = 1;\r\n}\r\nbreak;\r\ncase third_key:\r\nif(led[3] == 1) {\r\ndigitalWrite(third_led_pin, LOW);\r\nled[3] = 0;\r\n} else {\r\ndigitalWrite(third_led_pin, HIGH);\r\nled[3] = 1;\r\n}\r\nbreak;\r\ncase fourth_key:\r\nif(led[4] == 1) {\r\ndigitalWrite(fourth_led_pin, LOW);\r\nled[4] = 0;\r\n} else {\r\ndigitalWrite(fourth_led_pin, HIGH);\r\nled[4] = 1;\r\n}\r\nbreak;\r\n}\r\nSerial.println(value);\r\nreceiver.resume();\r\n}\r\n}<\/pre>\n<p>an old Philips TV remote showed codes for buttons 1-0 and Off - note contact bounce repeats;<br \/>\n01:20:47.878 -&gt; 9985<br \/>\n01:20:48.010 -&gt; 9985<br \/>\n01:20:50.492 -&gt; 9986<br \/>\n01:20:54.363 -&gt; 9987<br \/>\n01:20:54.462 -&gt; 9987<br \/>\n01:20:56.845 -&gt; 9988<br \/>\n01:20:56.944 -&gt; 9988<br \/>\n01:20:58.201 -&gt; 9989<br \/>\n01:20:58.301 -&gt; 9989<br \/>\n01:21:00.121 -&gt; 9990<br \/>\n01:21:00.220 -&gt; 9990<br \/>\n01:21:01.610 -&gt; 9991<br \/>\n01:21:01.709 -&gt; 9991<br \/>\n01:21:02.999 -&gt; 9992<br \/>\n01:21:03.099 -&gt; 9992<br \/>\n01:21:05.084 -&gt; 9993<br \/>\n01:21:05.183 -&gt; 9993<br \/>\n01:21:06.507 -&gt; 9984<br \/>\n01:21:06.639 -&gt; 9984<br \/>\n01:21:14.778 -&gt; 9996<br \/>\n01:21:17.624 -&gt; 9996<br \/>\n01:21:19.510 -&gt; 9996<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Old remotes can be re-purposed: Following this Post using the IR sensor connections - forget the LEDs just for reading codes: #include &lt;IRremote.h&gt; #define first_key 48703 #define second_key 58359 #define third_key 539 #define fourth_key 25979 int receiver_pin = 8; int first_led_pin = 7; int second_led_pin = 6; int third_led_pin = 5; int fourth_led_pin = 4; <a href=\"https:\/\/stevepedwards.today\/ElectronicsStuff\/reading-remote-control-codes-with-arduino\/\" class=\"more-link\">...<span class=\"screen-reader-text\">  Reading Remote Control Codes With Arduino<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,2],"tags":[],"class_list":["post-8677","post","type-post","status-publish","format-standard","hentry","category-tech-studies","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/posts\/8677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/comments?post=8677"}],"version-history":[{"count":1,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/posts\/8677\/revisions"}],"predecessor-version":[{"id":10073,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/posts\/8677\/revisions\/10073"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/media?parent=8677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/categories?post=8677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/tags?post=8677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}