{"id":8864,"date":"2018-04-25T01:24:22","date_gmt":"2018-04-25T05:24:22","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=8864"},"modified":"2018-04-25T03:43:29","modified_gmt":"2018-04-25T07:43:29","slug":"arduino-tutorials-for-testers-decoding-of-ir-receiver","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/arduino-tutorials-for-testers-decoding-of-ir-receiver\/","title":{"rendered":"Arduino Tutorials for Testers: Decoding of IR Remote"},"content":{"rendered":"<p>This is the seventh tutorial of Arduino tutorial series. In this tutorial, you will learn about how to decode the IR Remote and you will know about what kind of opportunities it will open for you.<\/p>\n<hr \/>\n<h3>Components Required:<\/h3>\n<ol>\n<li>Arduino Board<\/li>\n<li>Jumper Wires<\/li>\n<li>IR Remote<\/li>\n<li>IR Receiver: Following fig. 1 shows the IR Receiver. It has 3 pins: Output, GND, and Vcc. You can identify the pins by looking at fig. 1.\u00a0 IR receiver receives the IR signals from IR remote and decodes that signal. For this tutorial, we used HX1838 model of IR Receiver. It supports the IR remote which operates at 38 KHz. You can check the datasheet <a href=\"http:\/\/dalincom.ru\/datasheet\/AX-1838HS.pdf\">here<\/a>.\n<p><figure id=\"attachment_8865\" aria-describedby=\"caption-attachment-8865\" style=\"width: 247px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/ir-receiver.jpg\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8865\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/ir-receiver.jpg\" alt=\"IR Receiver\" width=\"247\" height=\"378\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/ir-receiver.jpg 247w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/ir-receiver-196x300.jpg 196w\" sizes=\"auto, (max-width: 247px) 100vw, 247px\" \/><\/a><figcaption id=\"caption-attachment-8865\" class=\"wp-caption-text\">Fig. 1 IR Receiver<\/figcaption><\/figure><\/li>\n<\/ol>\n<p><strong>Note:<\/strong> You can get these components fairly easily at many places (including online). We bought for our engineers this <a href=\"https:\/\/www.amazon.in\/dp\/B01KNR581U\/ref=ox_ya_os_product\">Arduino super-starter kit<\/a>.<\/p>\n<hr \/>\n<h3>Interfacing of IR Receiver with Arduino Uno:<\/h3>\n<figure id=\"attachment_8866\" aria-describedby=\"caption-attachment-8866\" style=\"width: 809px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interfacing_with_ir_receiver.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8866\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interfacing_with_ir_receiver.png\" alt=\"Interfacing of IR Receiver with Arduino Uno\" width=\"809\" height=\"489\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interfacing_with_ir_receiver.png 809w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interfacing_with_ir_receiver-300x181.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/interfacing_with_ir_receiver-768x464.png 768w\" sizes=\"auto, (max-width: 809px) 100vw, 809px\" \/><\/a><figcaption id=\"caption-attachment-8866\" class=\"wp-caption-text\">Fig. 2 Interfacing of IR Receiver with Arduino Uno<\/figcaption><\/figure>\n<p>Above fig. 2 shows the interfacing\u00a0of IR Receiver with Arduino Uno. Interfacing\u00a0of IR receiver is very easy. You need to just connect 3 pins of IR Receiver to Arduino. You can use a breadboard or you can use M2F (male to female) jumper wires for connection.<\/p>\n<p>Wiring Details:<\/p>\n<ol>\n<li>Connect the Vcc pin of IR\u00a0receiver to Vcc pin of Arduino board<\/li>\n<li>Connect the GND pin of IR\u00a0receiver to GND pin of Arduino board<\/li>\n<li>Connect the Output\u00a0signal pin to pin 11 of Arduino board<\/li>\n<\/ol>\n<hr \/>\n<h3>Write a code to decode IR Remote signals:<\/h3>\n<p>For decoding the IR Remote, we are going to use <strong>IRremote<\/strong>\u00a0Library. To get set up with the IRremote\u00a0library follow below steps:<\/p>\n<ul>\n<li>Download latest IRremote library from <a href=\"https:\/\/www.arduinolibraries.info\/libraries\/i-rremote\">here<\/a>.<\/li>\n<li>Unzip the file and rename the folder name to &#8216;IRremote&#8217;<\/li>\n<li>Move &#8216;IRremote&#8217; folder to your Arduino_Root\/libraries folder. On my Windows machine, it is located at C:\\Program Files (x86)\\Arduino\\libraries<\/li>\n<li>If you see a folder with name \u201cRobotIRremote\u201d under Arduino_Root\/libraries, please delete that folder. The library &#8216;RobotIRremote&#8217; has similar definitions to &#8216;IRremote&#8217; library and causes errors.(src: <a href=\"https:\/\/github.com\/z3t0\/Arduino-IRremote\">point 5 of setup instructions<\/a>)<\/li>\n<\/ul>\n<h4>Arduino Sketch\/Code:<\/h4>\n<pre lang=\"arduino\">#include <IRremote.h>\r\nint RECV_PIN = 11; \/\/ Declare variables to hold pin number\r\nIRrecv irrecv(RECV_PIN); \/\/ Create irrecv object\r\ndecode_results results; \/\/ declare variable to hold decoded IR receiver result\r\n\r\nvoid setup(){\r\n\/\/ put your setup code here, to run once:\r\nSerial.begin(9600); \/\/Initialize serial monitor\r\nSerial.println(\"Enabling IR Receiver\"); \/\/ Print text on serial monitor\r\nirrecv.enableIRIn(); \/\/ Start the IR receiver\r\nSerial.println(\"Enabled IR Receiver\"); \/\/ Print text on serial monitor\r\n}\r\n\r\nvoid loop() {\r\n\/\/ put your main code here, to run repeatedly:\r\nif (irrecv.decode(&results)) \/\/ Checks the code received or not\r\n{\r\nSerial.print(\"Decoded Signal = \"); \/\/Print text on serial monitor\r\nSerial.println(results.value); \/\/ Print the decoded value on serial monitor\r\nirrecv.resume(); \/\/ continue to receive the next value\r\n}\r\ndelay(100);\r\n}\r\n<\/pre>\n<p>Upload above sketch\/code on Arduino and open serial monitor. Now, press and hold (or press frequently) any of the buttons on IR remote and you will see the decoded value of that specific button printed on serial monitor multiple times. You can check the decoded values for all buttons and take a note of that decoded code. You can use the decoded codes in a script to control some actions, for example, Turning ON\/OFF of Light\/TV in a home automation system.<\/p>\n<hr \/>\n<h3>Practice Task:<\/h3>\n<p>Once, you are able to decode the IR remote, it will open a lot of opportunities for you to control other devices using the remote. For example, you can do following tasks using IR remote:<\/p>\n<ul>\n<li>Control Servo Motor Angle<\/li>\n<li>Control Home Appliances<\/li>\n<li>Control LED\u2019s<\/li>\n<li>Control Robot<\/li>\n<\/ul>\n<hr \/>\n<p>Hope you liked this tutorial. In this tutorial, you learned a new skill &#8211; controlling things wirelessly. Look at our next tutorial <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorials-for-testers-stepper-motor\/\">here<\/a>, you will learn how to interface stepper motor with Arduino and how to move rotor accurately to a specific angle. If you follow along, at the end of this <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorial-series-for-testers\/\">series<\/a>, you will distinguish how hardware devices\/instruments\/products designed, you can guess how they programmed and you will get ideas about how to test them too.<\/p>\n<p><strong>Learn more <a href=\"https:\/\/qxf2.com\/blog\/about-qxf2\/\">about Qxf2 Services<\/a>.<\/strong><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>This is the seventh tutorial of Arduino tutorial series. In this tutorial, you will learn about how to decode the IR Remote and you will know about what kind of opportunities it will open for you. Components Required: Arduino Board Jumper Wires IR Remote IR Receiver: Following fig. 1 shows the IR Receiver. It has 3 pins: Output, GND, and [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[159],"tags":[119,162],"class_list":["post-8864","post","type-post","status-publish","format-standard","hentry","category-arduino","tag-arduino","tag-ir-receiver"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=8864"}],"version-history":[{"count":24,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8864\/revisions"}],"predecessor-version":[{"id":9315,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8864\/revisions\/9315"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=8864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=8864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=8864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}