{"id":978,"date":"2015-07-27T16:44:22","date_gmt":"2015-07-27T06:44:22","guid":{"rendered":"http:\/\/bandetech.com\/blog\/?page_id=978"},"modified":"2015-07-27T16:52:33","modified_gmt":"2015-07-27T06:52:33","slug":"infrared-remote-technical-guide","status":"publish","type":"page","link":"https:\/\/bandetech.com\/blog\/infrared-remote-technical-guide\/","title":{"rendered":"Infrared remote \u2014 Technical guide"},"content":{"rendered":"<p>This is the outline of the Arduino code and schematics for the <a href=\"http:\/\/bandetech.com\/blog\/2015\/07\/remote-enhancements\/\">Remote Enhancements<\/a> project.<\/p>\n<p>This was a two-part project: Firstly,\u00a0determine the codes coming\u00a0from the TV&#8217;s remote control; Secondly,\u00a0to listen for and respond to specific\u00a0codes.<\/p>\n<p>The set up and Arduino code for the first part is remarkably\u00a0simple. Connect\u00a0the IR receiver module to power, ground and a digital input pin on the Arduino. Upload the code\u00a0to the Arduino (make sure the correct pin is specified\u00a0in the code)\u00a0and then open the serial monitor.\u00a0When a button\u00a0on a remote control is pressed, the associated code is displayed in the Arduino&#8217;s Serial Monitor window.<\/p>\n<div class=\"tiled-gallery type-rectangular tiled-gallery-unresized\" data-original-width=\"584\" data-carousel-extra='null' itemscope itemtype=\"http:\/\/schema.org\/ImageGallery\" > <div class=\"gallery-row\" style=\"width: 584px; height: 206px;\" data-original-width=\"584\" data-original-height=\"206\" > <div class=\"gallery-group images-1\" style=\"width: 318px; height: 206px;\" data-original-width=\"318\" data-original-height=\"206\" > <div class=\"tiled-gallery-item tiled-gallery-item-large\" itemprop=\"associatedMedia\" itemscope itemtype=\"http:\/\/schema.org\/ImageObject\"> <a href=\"https:\/\/i0.wp.com\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_reader_circuit.png?ssl=1\" border=\"0\" itemprop=\"url\" rel=\"lightbox[978]\"> <meta itemprop=\"width\" content=\"314\"> <meta itemprop=\"height\" content=\"202\"> <img decoding=\"async\" class=\"\" data-attachment-id=\"981\" data-orig-file=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_reader_circuit.png\" data-orig-size=\"532,343\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Circuit diagram\" data-image-description=\"\" data-medium-file=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_reader_circuit-300x193.png\" data-large-file=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_reader_circuit.png\" src=\"https:\/\/i0.wp.com\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_reader_circuit.png?w=314&#038;h=202&#038;ssl=1\" srcset=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_reader_circuit.png 532w, https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_reader_circuit-300x193.png 300w, https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_reader_circuit-465x300.png 465w\" width=\"314\" height=\"202\" loading=\"lazy\" data-original-width=\"314\" data-original-height=\"202\" itemprop=\"http:\/\/schema.org\/image\" title=\"Circuit diagram\" alt=\"Circuit diagram\" style=\"width: 314px; height: 202px;\" \/> <\/a> <\/div> <\/div> <!-- close group --> <div class=\"gallery-group images-1\" style=\"width: 266px; height: 206px;\" data-original-width=\"266\" data-original-height=\"206\" > <div class=\"tiled-gallery-item tiled-gallery-item-large\" itemprop=\"associatedMedia\" itemscope itemtype=\"http:\/\/schema.org\/ImageObject\"> <a href=\"https:\/\/i0.wp.com\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_serial_output.jpg?ssl=1\" border=\"0\" itemprop=\"url\" rel=\"lightbox[978]\"> <meta itemprop=\"width\" content=\"262\"> <meta itemprop=\"height\" content=\"202\"> <img decoding=\"async\" class=\"\" data-attachment-id=\"979\" data-orig-file=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_serial_output.jpg\" data-orig-size=\"408,315\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;BryceC&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Output\" data-image-description=\"\" data-medium-file=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_serial_output-300x232.jpg\" data-large-file=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_serial_output.jpg\" src=\"https:\/\/i0.wp.com\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_serial_output.jpg?w=262&#038;h=202&#038;ssl=1\" srcset=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_serial_output.jpg 408w, https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_serial_output-300x232.jpg 300w, https:\/\/bandetech.com\/blog\/wp-content\/uploads\/htpc_remote_serial_output-389x300.jpg 389w\" width=\"262\" height=\"202\" loading=\"lazy\" data-original-width=\"262\" data-original-height=\"202\" itemprop=\"http:\/\/schema.org\/image\" title=\"Output\" alt=\"Output\" style=\"width: 262px; height: 202px;\" \/> <\/a> <\/div> <\/div> <!-- close group --> <\/div> <!-- close row --> <\/div>\n<pre class=\"brush: arduino; title: ; notranslate\" title=\"\">\r\n\/*\r\nIR Remote code reader\r\n\r\nThe circuit: IR module to d10\r\n\r\n*\/\r\n\r\n#include &lt;IRremote.h&gt;\r\n#define IRPIN 10\r\n\r\nIRrecv irrecv(IRPIN); \/\/ create instance of 'irrecv' on IRPIN\r\ndecode_results results; \/\/ variable to hold incoming codes\r\n\r\nvoid setup() {\r\n  irrecv.enableIRIn(); \/\/ Start the receiver\r\n  Serial.begin(9600);\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ 2Hz flash of onboard LED\r\n  digitalWrite(13, HIGH);\r\n  delay(20);\r\n  digitalWrite(13, LOW);\r\n  delay(480);\r\n\r\n  if (irrecv.decode(&amp;amp;results)) {\r\n    irCheck();\r\n    irrecv.resume();\r\n  }\r\n} \/\/ end main loop\r\n\r\nvoid irCheck() {\r\n  Serial.println(results.value);\r\n}\r\n<\/pre>\n<p>For the final project goal, digital pin d05 was\u00a0connected to the PC&#8217;s power-on wire (green from the ATX power supply). When this line is connected to ground (via a digital LOW signal), the computer starts. The servo motor was mechanically attached to the HDMI switch and a servo horn was attached\u00a0to act as a short lever. When the servo moves a few degrees, the button on top of the HDMI switch is pressed down. The amount of servo movement needed was determined by trial and error.<\/p>\n<p><a href=\"http:\/\/bandetech.com\/blog\/wp-content\/uploads\/IR-remote-HDMI-PC-Power-on.png\" rel=\"lightbox[978]\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-985 size-full\" src=\"http:\/\/bandetech.com\/blog\/wp-content\/uploads\/IR-remote-HDMI-PC-Power-on.png\" alt=\"IR remote HDMI + PC Power on\" width=\"709\" height=\"379\" srcset=\"https:\/\/bandetech.com\/blog\/wp-content\/uploads\/IR-remote-HDMI-PC-Power-on.png 709w, https:\/\/bandetech.com\/blog\/wp-content\/uploads\/IR-remote-HDMI-PC-Power-on-300x160.png 300w, https:\/\/bandetech.com\/blog\/wp-content\/uploads\/IR-remote-HDMI-PC-Power-on-500x267.png 500w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/a><\/p>\n<pre class=\"brush: arduino; title: ; notranslate\" title=\"\">\r\n\r\n\/*\r\n\r\nIR Remote on for HTPC\r\nv1.0 150719 - Set up IR receiver\r\nv1.1 150722 - Add servo for HDMI switcher\r\n\r\n  The circuit:\r\n * IR LED data to d10\r\n * Output d05, active low, to ground power-on rail\r\n * Servo on d09\r\n\r\n Remote Signals from Samsung TV control\r\n 470021382 = STB\r\n 2088030026 = CABLE\r\n 4200456840 = VCR\r\n 1625891106 = TV\r\n\r\n*\/\r\n\r\n#include &lt;IRremote.h&gt;\r\n#include &lt;Servo.h&gt; \r\n\r\n#define IRPIN 10\r\n#define onPIN 5\r\n#define svoPIN 9\r\n#define svoUP 147\r\n#define svoDN 127\r\n\r\nServo myservo;            \/\/ create servo object to control a servo\r\nIRrecv irrecv(IRPIN);     \/\/ create instance of 'irrecv' on IRPIN\r\ndecode_results results;   \/\/ variable to hold incoming codes\r\n\r\n\/\/ Global variables\r\n\r\nvoid setup() {\r\n  pinMode(onPIN, OUTPUT);   \/\/ set the power-on pin for output and active LOW\r\n  digitalWrite(onPIN, HIGH);\r\n  irrecv.enableIRIn();      \/\/ Start the receiver\r\n  myservo.attach(svoPIN);   \/\/ attaches the svoPIN to the servo object\r\n  myservo.write(svoUP);\r\n  delay(75);\r\n  myservo.detach();\r\n\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ 2Hz flash of onboard LED\r\n  digitalWrite(13, HIGH);\r\n  delay(20);\r\n  digitalWrite(13, LOW);\r\n  delay(480);\r\n\r\n  if (irrecv.decode(&amp;results)) {    \/\/ New code received? See if it needs action and then restart the IR receiver\r\n    irCheck();\r\n    irrecv.resume();\r\n    }\r\n}  \/\/ end main loop\r\n\r\nvoid irCheck() {\r\n\/\/ If the value received matches stored code for PC power on,\r\n\/\/ set onPIN LOW for 0.5s &amp; long-flash onboard LED\r\n\/\/ or HDMI switch, then activate servo\r\n\r\n  if (results.value == 470021382) {         \/\/ code to turn PC on\r\n    digitalWrite(onPIN, LOW);               \/\/ ground power on pin\r\n    digitalWrite(13, HIGH);\r\n    delay(500);                             \/\/ wait a moment\r\n    digitalWrite(onPIN, HIGH);              \/\/ return power pin to HIGH state\r\n    digitalWrite(13, LOW);\r\n    delay(200);\r\n    }\r\n  else if (results.value == 2088030026) {   \/\/ code to activate HDMI switch\r\n    myservo.attach(svoPIN);                 \/\/ attach servo interrupt first\r\n    myservo.write(svoDN);                   \/\/ move to pressed position\r\n    digitalWrite(13, HIGH);\r\n    delay(80);                              \/\/ delay to give servo time to move\r\n    myservo.write(svoUP);                   \/\/ return servo to up position\r\n    delay(30);                              \/\/ delay to give servo time to move\r\n    digitalWrite(13, LOW);\r\n    myservo.detach();                       \/\/ detach servo object to stop jitter\r\n  }\r\n\r\n}    \/\/ end irCheck\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the outline of the Arduino code and schematics for the Remote Enhancements project. This was a two-part project: Firstly,\u00a0determine the codes coming\u00a0from the TV&#8217;s remote control; Secondly,\u00a0to listen for and respond to specific\u00a0codes. The set up and Arduino &hellip; <a href=\"https:\/\/bandetech.com\/blog\/infrared-remote-technical-guide\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":995,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-978","page","type-page","status-publish","has-post-thumbnail","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P8H2X3-fM","_links":{"self":[{"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/pages\/978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/comments?post=978"}],"version-history":[{"count":10,"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/pages\/978\/revisions"}],"predecessor-version":[{"id":996,"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/pages\/978\/revisions\/996"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/media\/995"}],"wp:attachment":[{"href":"https:\/\/bandetech.com\/blog\/wp-json\/wp\/v2\/media?parent=978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}