{"id":392,"date":"2008-07-06T11:05:43","date_gmt":"2008-07-06T15:05:43","guid":{"rendered":"http:\/\/mini.local\/blog\/index.php?entry=entry080706-110543"},"modified":"2008-07-06T11:05:43","modified_gmt":"2008-07-06T15:05:43","slug":"ir-interfacing-with-a-led-messgage-sign-part-2","status":"publish","type":"post","link":"https:\/\/biosrhythm.com\/?p=392","title":{"rendered":"IR interfacing with a LED messgage sign, part 2"},"content":{"rendered":"<p><a href=\"http:\/\/www.biosrhythm.com\/wp-content\/images\/arduino-ir-emitter.jpg\" target=\"_blank\"><img loading=\"lazy\" src=\"http:\/\/www.biosrhythm.com\/wp-content\/images\/arduino-ir-emitter.jpg\" width=\"484\" height=\"363\" border=\"0\" alt=\"\" \/><\/a><br \/>To make the Arduino transmit IR signals, you need an IR LED.  I found a couple from an old Sun optical mouse and an old TV remote control.  I used two emitters because that&#039;s what the original Pro-Lite remote has inside and it also gains distance (I hoped).  I should probably be connecting these LEDs through a resistor and at various stages I did.  But I figured the pulses were so short that it _may_ be ok.  Besides, there&#039;s more where that came from.<\/p>\n<p>I started the IR emitter sketch from <a href=\"http:\/\/www.arduino.cc\/cgi-bin\/yabb2\/YaBB.pl?num=1176098434\" target=\"_blank\" >this Arduino forum post<\/a>.  Actually, the part that was most interesting, was how to modulate the LED at a certain frequency.<br \/><code><br \/>\/\/ this will write an oscillation at 38KHz for a certain time in useconds<br \/>void oscillationWrite(int pin, int time) {<br \/>  for(int i = 0; i <= time\/26; i++) {<br \/>    digitalWrite(pin, HIGH);<br \/>    delayMicroseconds(13);<br \/>    digitalWrite(pin, LOW);<br \/>    delayMicroseconds(13);<br \/>  }<br \/>}<br \/><\/code><br \/>This was to be the key to making it all work.  I have no way of knowing if the actual modulation of the Pro-Lite IR remote is 38KHz but it seemed to work.<\/p>\n<p>The next step was to pack the pulse widths into the five known types to put it into code.  Perl to the rescue again.<br \/><code><br \/>A: S001011110110SRS001011110110SRS00100000<br \/>B: S001010001011SRS001010001011SRS00101000<br \/>C: S001010100011SRS001010100011SRS00100000<br \/>..<br \/>M: S001001000010SRS001001000010SRS00100100<br \/>..<br \/>X: S001011101011SRS001011101011SRS00101110<br \/>Y: S001010001110SRS001010001110SRS00101000<br \/>Z: S001011111010SRS001011111010SRS00101111<br \/><\/code><br \/>You&#039;ll notice I said five types yet there are only four represented above.  That&#039;s because the five pulse (which I&#039;ve called null) is between every pulse (the dip down to 0 on the graph).  You&#039;ll also notice that the bitstreams always begin with &#8220;S0010&#8221; which I&#039;ve hard coded since every pulse begins with it.  You&#039;ll also notice the bitstream repeats a few times.  So, when you reduce and remove repeats, you&#039;re left with this.<br \/><code><br \/>A: 11110110<br \/>B: 10001011<br \/>C: 10100011<br \/>..<br \/><\/code><br \/>Which reduces further into decimal, saving valuable memory space on the Arduino.<br \/><code><br \/>int A = 246;<br \/>int B = 139;<br \/>int C = 163;<br \/>int D = 170;<br \/>int E = 166;<br \/>int F = 202;<br \/>int G = 135;<br \/>int H = 10;<br \/>int I = 78;<br \/>..<br \/><\/code><br \/>Next up, finish up the code and give it a test drive.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To make the Arduino transmit IR signals, you need an IR LED. I found a couple from an old Sun optical mouse and an old TV remote control. I used two emitters because that&#039;s what the original Pro-Lite remote has inside and it also gains distance (I hoped). I should probably be connecting these LEDs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,8],"tags":[],"_links":{"self":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts\/392"}],"collection":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=392"}],"version-history":[{"count":0,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts\/392\/revisions"}],"wp:attachment":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}