This is a work in progress of how I made my universal remote to control my TV, Mac mini, Direct TV, and surround sound all from my iPhone.

Here is the gist of how the project works: A virtual machine of Ubuntu 12.04 running Nginx hosts the website which is the interface for the universal remote. With the push of a button on the website the website sends a command to the Arduino. The Arduino receives the command from its ethernet shield and then uses the IRremote library to interpret the command as a IR signal.

On a small board I attached an IR receiver and transmitter like so:

Receiver

ARDUINO PIN 11 -----330R---- IR REC PIN1

ARDUINO PIN GND ------------- IR REC PIN2

ARDUINO PIN 5V----------------- IR REC PIN3

Transmitter

ARDUINO PIN PWM 3 --------- IR TRAN long pin

ARDUINO GND -------330R----- IR TRAN short pin

I got my parts from SparkFun. Here is the receiver transmitter I got: https://www.sparkfun.com/products/241

Here is the web interface that runs on my Nginx web server:

  1.  
  2. <!DOCTYPE html>
  3.  <html lang="en">
  4.  <head>
  5.         <meta charset="utf-8">
  6.         <meta name="viewport" content="width=device-width, initial-scale=1">
  7.         <title>Remote</title>
  8.         <link rel="stylesheet"  href="css/themes/default/jquery.mobile-1.1.1.css" />
  9.         <link rel="stylesheet" href="docs/_assets/css/jqm-docs.css" />
  10.         <script src="js/jquery.js"></script>
  11.         <script src="docs/_assets/js/jqm-docs.js"></script>
  12.         <script src="js/jquery.mobile-1.1.1.js"></script>
  13.         <link rel="apple-touch-icon" href="images/power-button-off-md.png" />
  14.  </head>
  15.  <body>
  16.  
  17. <script>
  18.  
  19. function allpower()
  20. {
  21.         var xmlhttp =  new XMLHttpRequest();
  22.         xmlhttp.open("POST","http://192.168.0.9/4550,4450,650,1600,650,1600,650,1600,650,500,600,500,650,500,600,500,650,500,650,1600,600,1650,600,1650,600,500,650,500,600,550,600,500,650,500,600,500,650,1600,650,500,600,500,650,500,600,500,650,500,650,500,600,1600,650,500,650,1600,650,1600,600,1650,600,1650,600,1650,600,1600,650/", true);
  23.         xmlhttp.send();
  24.  
  25.         var xmlhttp =  new XMLHttpRequest();
  26.         xmlhttp.open("POST","http://192.168.0.9/8950,4500,650,1550,650,500,650,1550,650,500,650,450,650,500,650,450,650,1600,650,1600,600,500,650,1600,650,1550,650,500,650,1550,650,1600,650,1600,650,450,650,500,650,450,650,1600,650,450,650,500,650,450,650,450,650,1600,650,1600,600,1650,650,450,650,1600,650,1600,600,1600,650,1600,650/", true);
  27.         xmlhttp.send();
  28.  
  29.         var xmlhttp =  new XMLHttpRequest();
  30.         xmlhttp.open("POST","http://192.168.0.9/6000,1150,1250,1150,650,550,650,550,650,1150,650,550,650,550,650,1150,650,1150,650/", true);
  31.         xmlhttp.send();
  32. }
  33.  
  34.  
  35.  
  36. function appleprevious()
  37. {
  38.         var xmlhttp =  new XMLHttpRequest();
  39.         xmlhttp.open("POST","http://192.168.0.9/9200,4500,650,500,650,1650,700,1600,700,1650,650,500,700,1600,650,1650,650,1650,650,1700,650,1650,650,1650,650,500,650,550,650,500,650,550,650,1650,650,1650,650,500,700,500,650,1650,650,550,650,500,650,500,700,500,650,500,700,1600,700,1650,650,1650,650,1650,650,500,650,550,650,1650,650/", true);
  40.         xmlhttp.send();
  41. }
  42.  
  43. function applemenu()
  44. {
  45.         var xmlhttp =  new XMLHttpRequest();
  46.         xmlhttp.open("POST","http://192.168.0.9/9200,4500,650,500,650,1650,650,1650,700,1600,700,500,650,1650,650,1650,650,1650,650,1650,700,1600,700,1650,650,500,650,550,650,500,650,550,650,1650,650,1650,650,1650,650,550,650,500,650,550,650,500,650,500,700,500,650,500,700,1650,650,1650,650,1650,650,1650,650,500,700,500,650,1650,650/", true);
  47.         xmlhttp.send();
  48. }
  49.  
  50. function appleplay()
  51. {
  52.         var xmlhttp =  new XMLHttpRequest();
  53.         xmlhttp.open("POST","http://192.168.0.9/9200,4500,650,500,650,1650,650,1650,700,1650,650,500,650,1650,650,1650,650,1650,650,1650,700,1600,700,1600,700,500,650,550,650,500,650,500,700,1650,650,1650,650,500,650,1650,650,550,650,500,650,550,600,550,650,550,650,500,650,1650,650,1650,650,1650,650,1700,650,500,650,500,700,1650,650/", true);
  54.         xmlhttp.send();
  55. }
  56.  
  57. function appleprevious()
  58. {
  59.         var xmlhttp =  new XMLHttpRequest();
  60.         xmlhttp.open("POST","http://192.168.0.9/9200,4550,600,550,650,1650,650,1650,650,1700,600,550,650,1650,650,1650,650,1700,600,1700,600,1700,650,1650,650,550,600,550,650,550,600,550,650,1650,650,1700,600,550,650,550,600,1700,650,500,650,550,650,500,650,550,650,550,600,1700,600,1700,600,1700,650,1650,650,550,600,550,650,1650,650/", true);
  61.         xmlhttp.send();
  62. }
  63.  
  64. function applenext()
  65. {
  66.         var xmlhttp =  new XMLHttpRequest();
  67.         xmlhttp.open("POST","http://192.168.0.9/9200,4500,650,550,650,1650,650,1650,650,1650,650,550,650,1650,650,1650,650,1650,650,1650,650,1650,650,1650,650,550,650,500,700,500,650,500,650,1650,700,500,650,1650,650,1650,650,550,600,550,650,550,650,500,650,550,650,500,650,1650,650,1650,650,1650,700,1600,700,500,650,550,650,1650,650/", true);
  68.         xmlhttp.send();
  69. }
  70.  
  71. function tvpower()
  72. {
  73.         var xmlhttp =  new XMLHttpRequest();
  74.         xmlhttp.open("POST","http://192.168.0.9/4550,4450,650,1600,650,1600,650,1600,650,500,600,500,650,500,600,500,650,500,650,1600,600,1650,600,1650,600,500,650,500,600,550,600,500,650,500,600,500,650,1600,650,500,600,500,650,500,600,500,650,500,650,500,600,1600,650,500,650,1600,650,1600,600,1650,600,1650,600,1650,600,1600,650/", true);
  75.         xmlhttp.send();
  76. }
  77.  
  78. function receiverpower()
  79. {
  80.         var xmlhttp =  new XMLHttpRequest();
  81.         xmlhttp.open("POST","http://192.168.0.9/8950,4500,650,1550,650,500,650,1550,650,500,650,450,650,500,650,450,650,1600,650,1600,600,500,650,1600,650,1550,650,500,650,1550,650,1600,650,1600,650,450,650,500,650,450,650,1600,650,450,650,500,650,450,650,450,650,1600,650,1600,600,1650,650,450,650,1600,650,1600,600,1600,650,1600,650/", true);
  82.         xmlhttp.send();
  83. }
  84.  
  85. function receivervolup()
  86. {
  87.         var xmlhttp =  new XMLHttpRequest();
  88.         xmlhttp.open("POST","http://192.168.0.9/9000,4450,600,1600,650,500,600,1650,600,500,600,500,650,500,600,500,650,1600,600,1650,600,500,600,1650,600,1600,650,500,600,1650,600,1600,650,1600,650,1600,600,500,650,500,600,500,650,450,650,1600,600,1650,600,500,650,500,600,1600,650,1600,650,1600,600,1650,600,500,650,450,650,1600,650/", true);
  89.         xmlhttp.send();
  90. }
  91.  
  92. function receivervoldown()
  93. {
  94.         var xmlhttp =  new XMLHttpRequest();
  95.         xmlhttp.open("POST","http://192.168.0.9/9000,4450,600,1650,600,500,600,1650,600,500,600,500,650,500,600,500,650,1600,600,1650,600,500,600,1650,600,1650,600,500,600,1650,600,1600,650,1600,650,500,600,500,600,500,650,500,600,500,600,1650,600,1650,600,500,600,1650,600,1600,650,1600,650,1600,600,1650,600,500,600,500,650,1600,650/", true);
  96.         xmlhttp.send();
  97. }
  98.  
  99. function receivermacmini()
  100. {
  101.         var xmlhttp =  new XMLHttpRequest();
  102.         xmlhttp.open("POST","http://192.168.0.9/9000,4450,600,1650,600,500,600,1650,600,500,600,500,650,500,600,500,650,1600,600,1650,600,500,600,1650,600,1600,650,500,600,1650,600,1600,650,1600,650,1600,600,500,650,1600,600,1650,600,500,650,1600,600,1650,600,500,650,450,650,1600,650,500,600,500,600,1650,600,500,600,500,650,1600,650/", true);
  103.         xmlhttp.send();
  104. }
  105.  
  106. function receiverdirecttv()
  107. {
  108.         var xmlhttp =  new XMLHttpRequest();
  109.         xmlhttp.open("POST","http://192.168.0.9/9000,4450,600,1600,650,500,600,1650,600,500,600,500,650,500,600,500,650,1600,600,1650,600,500,600,1650,600,1600,650,500,600,1650,600,1600,650,1600,650,500,600,500,600,500,650,500,600,1600,650,1600,650,1600,600,500,650,1600,600,1650,600,1650,600,1600,650,500,600,500,650,450,650,1600,650/", true);
  110.         xmlhttp.send();
  111. }
  112.  
  113. function receiverblueray()
  114. {
  115.         var xmlhttp =  new XMLHttpRequest();
  116.         xmlhttp.open("POST","http://192.168.0.9/9000,4450,600,1600,650,500,600,1650,600,500,600,500,650,500,600,500,600,1650,600,1600,650,500,600,1650,600,1600,650,500,600,1600,650,1600,650,1600,650,1600,600,1650,600,500,600,1650,600,500,600,1650,600,1600,650,500,600,500,650,500,600,1600,650,500,600,1650,600,500,600,500,650,1600,600/", true);
  117.         xmlhttp.send();
  118. }
  119.  
  120. function receiverairplay()
  121. {
  122.         var xmlhttp =  new XMLHttpRequest();
  123.         xmlhttp.open("POST","http://192.168.0.9/9000,4450,600,1650,600,500,650,1600,600,500,650,450,650,500,600,500,650,1600,600,1650,600,500,650,1600,600,1650,600,500,650,1600,600,1650,600,1600,650,500,600,1600,650,1600,650,500,600,1600,650,1600,650,1600,600,500,650,1600,600,500,650,500,600,1600,650,500,600,500,650,500,600,1600,650/", true);
  124.         xmlhttp.send();
  125. }
  126.  
  127. function directtvpower()
  128. {
  129.         var xmlhttp =  new XMLHttpRequest();
  130.         xmlhttp.open("POST","http://192.168.0.9/6050,1150,1250,1150,650,550,650,550,650,1150,650,550,650,550,650,1150,700,1100,650/", true);
  131.         xmlhttp.send();
  132. }
  133.  
  134. function directtvguide()
  135. {
  136.         var xmlhttp =  new XMLHttpRequest();
  137.         xmlhttp.open("POST","http://192.168.0.9/6000,1150,1300,1100,700,500,650,550,1250,550,1250,550,650,550,650,550,650,550,650/", true);
  138.         xmlhttp.send();
  139. }
  140.  
  141. function directtventer()
  142. {
  143.         var xmlhttp =  new XMLHttpRequest();
  144.         xmlhttp.open("POST","http://192.168.0.9/6000,1200,1250,1150,650,550,650,550,1250,550,600,1150,650,1150,1300,1100,1250,550,650/", true);
  145.         xmlhttp.send();
  146. }
  147. function directtvrecord()
  148. {
  149.         var xmlhttp =  new XMLHttpRequest();
  150.         xmlhttp.open("POST","http://192.168.0.9/6050,1150,1250,1150,650,550,650,550,1250,1150,650,1150,600,1150,650,550,1250,1150,650/", true);
  151.         xmlhttp.send();
  152. }
  153.  
  154. function directtvlist()
  155. {
  156.         var xmlhttp =  new XMLHttpRequest();
  157.         xmlhttp.open("POST","http://192.168.0.9/6050,1100,1250,1150,650,550,650,550,1250,550,1250,550,1200,600,600,550,1250,550,650/", true);
  158.         xmlhttp.send();
  159. }
  160.  
  161. function directtvleft()
  162. {
  163.         var xmlhttp =  new XMLHttpRequest();
  164.         xmlhttp.open("POST","http://192.168.0.9/5950,1250,1250,1150,650,550,650,550,1200,600,600,600,1200,1150,1250,1150,650,1150,650/", true);
  165.         xmlhttp.send();
  166. }
  167.  
  168. function directtvright()
  169. {
  170.         var xmlhttp =  new XMLHttpRequest();
  171.         xmlhttp.open("POST","http://192.168.0.9/6050,1150,1250,1150,650,550,650,550,1250,550,650,1150,650,550,1250,1150,650,1150,600/", true);
  172.         xmlhttp.send();
  173. }
  174.  
  175. function directtvdown()
  176. {
  177.         var xmlhttp =  new XMLHttpRequest();
  178.         xmlhttp.open("POST","http://192.168.0.9/6000,1200,1250,1150,650,550,650,550,1250,550,600,600,1200,600,1200,1200,600,550,650/", true);
  179.         xmlhttp.send();
  180. }
  181.  
  182. function directtvup()
  183. {
  184.         var xmlhttp =  new XMLHttpRequest();
  185.         xmlhttp.open("POST","http://192.168.0.9/6000,1200,1200,1200,600,600,600,600,1200,550,650,550,650,1150,1250,550,1250,1150,650/", true);
  186.         xmlhttp.send();
  187. }
  188.  
  189. function directtvexit()
  190. {
  191.         var xmlhttp =  new XMLHttpRequest();
  192.         xmlhttp.open("POST","http://192.168.0.9/6000,1150,1300,1100,700,500,650,550,1250,550,650,1150,1300,500,1250,1150,1250,1150,650/", true);
  193.         xmlhttp.send();
  194. }
  195.  
  196. function directtvmenu()
  197. {
  198.         var xmlhttp =  new XMLHttpRequest();
  199.         xmlhttp.open("POST","http://192.168.0.9/6000,1200,1250,1150,650,550,650,550,1250,550,650,550,650,550,1250,550,1250,550,650/", true);
  200.         xmlhttp.send();
  201. }
  202.  
  203. function directtvchannelup()
  204. {
  205.         var xmlhttp =  new XMLHttpRequest();
  206.         xmlhttp.open("POST","http://192.168.0.9/200,2350,900,3300,450/", true);
  207.         xmlhttp.open("POST","http://192.168.0.9/6000,1200,1250,1150,650,550,600,600,600,600,1250,1150,650,1150,1200,600,1200,550,650/", true);
  208.         xmlhttp.send();
  209. }
  210.  
  211. function directtvchanneldown()
  212. {
  213.         var xmlhttp =  new XMLHttpRequest();
  214.         xmlhttp.open("POST","http://192.168.0.9/6050,1150,1250,1100,650,550,650,550,650,550,1250,1150,1250,550,1250,550,1250,1150,650/", true);
  215.         xmlhttp.send();
  216. }
  217.  
  218. function directtvplay()
  219. {
  220.         var xmlhttp =  new XMLHttpRequest();
  221.         xmlhttp.open("POST","http://192.168.0.9/6000,1150,1250,1150,650,550,650,550,1250,1150,650,550,650,550,1250,1150,1250,1150,650/", true);
  222.         xmlhttp.send();
  223. }
  224.  
  225. function directtvpause()
  226. {
  227.         var xmlhttp =  new XMLHttpRequest();
  228.         xmlhttp.open("POST","http://192.168.0.9/3050,1150,1250,1150,650,550,650,550,1250,1150,650,550,1200,550,650,550,650,1150,650/", true);
  229.         xmlhttp.send();
  230. }
  231.  
  232. function directtvrewind()
  233. {
  234.         var xmlhttp =  new XMLHttpRequest();
  235.         xmlhttp.open("POST","http://192.168.0.9/6050,1150,1250,1150,650,550,650,550,1250,1150,650,550,1250,1150,650,550,1250,550,650/", true);
  236.         xmlhttp.send();
  237. }
  238.  
  239. function directtvfastforward()
  240. {
  241.         var xmlhttp =  new XMLHttpRequest();
  242.         xmlhttp.open("POST","http://192.168.0.9/6000,1150,1250,1150,650,550,650,550,1250,1150,650,1150,650,550,650,550,1250,550,650/", true);
  243.         xmlhttp.send();
  244. }
  245.  
  246. function directtv1()
  247. {
  248.         var xmlhttp =  new XMLHttpRequest();
  249.         xmlhttp.open("POST","http://192.168.0.9/6000,1200,1200,1150,650,550,650,550,650,550,650,550,650,1150,650,550,650,1150,650/", true);
  250.         xmlhttp.send();
  251. }
  252.  
  253. function directtv2()
  254. {
  255.         var xmlhttp =  new XMLHttpRequest();
  256.         xmlhttp.open("POST","http://192.168.0.9/6050,1150,1250,1150,600,550,650,550,650,550,650,550,1250,550,650,550,1250,550,650/", true);
  257.         xmlhttp.send();
  258. }
  259.  
  260. function directtv3()
  261. {
  262.         var xmlhttp =  new XMLHttpRequest();
  263.         xmlhttp.open("POST","http://192.168.0.9/6050,1150,1250,1150,650,550,650,550,650,550,600,600,1250,1100,650,550,1250,1150,650/", true);
  264.         xmlhttp.send();
  265. }
  266.  
  267. function directtv4()
  268. {
  269.         var xmlhttp =  new XMLHttpRequest();
  270.         xmlhttp.open("POST","http://192.168.0.9/6050,1150,1250,1150,650,550,650,550,650,550,650,1150,650,550,600,600,1200,1150,650/", true);
  271.         xmlhttp.send();
  272. }
  273.  
  274. function directtv5()
  275. {
  276.         var xmlhttp =  new XMLHttpRequest();
  277.         xmlhttp.open("POST","http://192.168.0.9/6000,1150,1250,1150,650,550,650,550,650,550,650,1150,650,1150,650,1150,650,550,650/", true);
  278.         xmlhttp.send();
  279. }
  280.  
  281. function directtv6()
  282. {
  283.         var xmlhttp =  new XMLHttpRequest();
  284.         xmlhttp.open("POST","http://192.168.0.9/6000,1150,1250,1150,650,550,650,550,650,550,650,1150,1250,550,650,1150,650,1150,650/", true);
  285.         xmlhttp.send();
  286. }
  287.  
  288. function directtv7()
  289. {
  290.         var xmlhttp =  new XMLHttpRequest();
  291.         xmlhttp.open("POST","http://192.168.0.9/5950,1200,1250,1150,650,550,650,550,650,550,650,1150,1250,1150,650,1150,1200,600,650/", true);
  292.         xmlhttp.send();
  293. }
  294.  
  295. function directtv8()
  296. {
  297.         var xmlhttp =  new XMLHttpRequest();
  298.         xmlhttp.open("POST","http://192.168.0.9/5950,1250,1250,1150,650,550,600,600,650,550,1200,600,600,600,600,1200,1200,550,650/", true);
  299.         xmlhttp.send();
  300. }
  301.  
  302. function directtv9()
  303. {
  304.         var xmlhttp =  new XMLHttpRequest();
  305.         xmlhttp.open("POST","http://192.168.0.9/5950,1250,1250,1150,650,550,650,550,600,600,1200,600,600,1150,650,1150,1250,1150,650/", true);
  306.         xmlhttp.send();
  307. }
  308.  
  309. function directtv0()
  310. {
  311.         var xmlhttp =  new XMLHttpRequest();
  312.         xmlhttp.open("POST","http://192.168.0.9/6000,1200,1250,1150,650,550,650,550,600,1200,600,600,600,1200,600,1200,1200,550,650/", true);
  313.         xmlhttp.send();
  314. }
  315.  
  316.  
  317. </script>
  318.  
  319.  
  320. <div class="ui-grid-a">
  321. <div class="ui-block-a"><a href="javascript:void(0)" onclick="tvpower();" data-mini="true" data-role="button">TV Power</a></div>
  322. </div>
  323.  
  324. <div data-role="collapsible-set">
  325.  
  326.         <div data-role="collapsible" data-collapsed="false">
  327.         <h3>Receiver Remote</h3>
  328.         <div class="ui-grid-a">
  329.         <div class="ui-block-a"><a href="javascript:void(0);" onclick="receiverpower()" data-mini="true" data-role="button">Power</a></div>
  330.         <div class="ui-block-b"><a href="javascript:void(0);" onclick="receivervolup()" data-mini="true" data-role="button">Vol Up</a></div>
  331.         <div class="ui-block-a"><br></div>
  332.         <div class="ui-block-b"><a href="javascript:void(0);" onclick="receivervoldown()" data-mini="true" data-role="button">Vol Down</a></div>
  333.         <div class="ui-block-a"><br></div>
  334.         <div class="ui-block-a"><a href="javascript:void(0);" onclick="receivermacmini()" data-mini="true" data-role="button">Mac Mini</a></div>
  335.         <div class="ui-block-b"><a href="javascript:void(0);" onclick="receiverdirecttv()" data-mini="true" data-role="button">Direct TV</a></div>
  336.         <div class="ui-block-a"><a href="javascript:void(0);" onclick="receiverblueray()" data-mini="true" data-role="button">Blue Ray</a></div>
  337.  
  338.         <div class="ui-block-b"><a href="javascript:void(0);" onclick="receiverairplay()" data-mini="true" data-role="button">AirPlay</a></div>
  339. </div>
  340. <div class="ui-grid-solo">
  341.         <div class="ui-block-a"></div>
  342. </div>
  343.         </div>
  344.  
  345.         <div data-role="collapsible">
  346.  
  347.  
  348.         <h3>Direct TV Remote</h3>
  349.  
  350.  
  351.         <div class="ui-grid-a">
  352.         <div class="ui-block-a"><a href="javascript:void(0);" onclick="directtvpower()" data-mini="true" data-role="button">Power</a></div>
  353. </div> 
  354. <div data-role="controlgroup" data-type="horizontal" data-mini="true">
  355.         <a href="javascript:void(0);" onclick="directtvguide()" data-role="button">Guide</a>
  356.         <a href="javascript:void(0);" onclick="directtvlist()" data-role="button">List</a>
  357.         <a href="javascript:void(0);" onclick="directtventer()" data-role="button">Entr</a>
  358.         <a href="javascript:void(0);" onclick="directtvexit()" data-role="button">Exit</a>
  359.         </div>
  360.  
  361. <div data-role="controlgroup" data-type="horizontal" data-mini="true">
  362. <a href="javascript:void(0);" onclick="directtvrecord()" data-role="button">Record</a>
  363. <a href="javascript:void(0);" onclick="directtvplay()" data-role="button">Play</a>
  364. <a href="javascript:void(0);" onclick="directtvpause()" data-role="button">Pause</a>
  365. <a href="javascript:void(0);" onclick="directtvmenu()" data-role="button">Menu</a>
  366. </div>
  367.  
  368. <div data-role="controlgroup" data-type="horizontal" data-mini="true">
  369.         <a href="javascript:void(0);" onclick="directtvrewind()" data-role="button">Rewind</a>
  370.         <a href="javascript:void(0);" onclick="directtvfastforward()" data-role="button">Fast Forward</a>
  371. </div>
  372.  
  373. <div class="ui-block-a"><br></div>
  374.         <div class="ui-block-b"><br></div>
  375.  
  376. <div data-role="controlgroup" data-type="horizontal">
  377.         <a href="javascript:void(0);" onclick="directtvleft()" data-icon="arrow-l" data-role="button"></a>
  378.         <a href="javascript:void(0);" onclick="directtvright()" data-icon="arrow-r"  data-role="button"></a>
  379.         <a href="javascript:void(0);" onclick="directtvup()" data-icon="arrow-u" data-role="button"></a>
  380.         <a href="javascript:void(0);" onclick="directtvdown()" data-icon="arrow-d" data-role="button"></a>
  381. </div>
  382.         <div data-role="controlgroup" data-type="horizontal" data-mini="true">
  383.         <div class="ui-block-a"><a href="javascript:void(0);" onclick="directtvchannelup()" data-role="button">Chan Up</a></div>
  384.         <div class="ui-block-a"><a href="javascript:void(0);" onclick="directtvchanneldown()" data-role="button">Chan Down</a></div>
  385.         </div>
  386.  
  387.         <div data-role="controlgroup" data-type="horizontal">
  388.         <a href="javascript:void(0);" onclick="directtv1()" data-role="button" data-inline="true" data-mini="true">1</a>
  389.         <a href="javascript:void(0);" onclick="directtv2()" data-role="button" data-inline="true" data-mini="true">2</a>
  390.         <a href="javascript:void(0);" onclick="directtv3()" data-role="button" data-inline="true" data-mini="true">3</a>
  391.         <a href="javascript:void(0);" onclick="directtv4()" data-role="button" data-inline="true" data-mini="true">4</a>
  392.         <a href="javascript:void(0);" onclick="directtv5()" data-role="button" data-inline="true" data-mini="true">5</a>
  393.         <a href="javascript:void(0);" onclick="directtv6()" data-role="button" data-inline="true" data-mini="true">6</a>
  394.         <a href="javascript:void(0);" onclick="directtv7()" data-role="button" data-inline="true" data-mini="true">7</a>
  395.         <a href="javascript:void(0);" onclick="directtv8()" data-role="button" data-inline="true" data-mini="true">8</a>
  396.         <a href="javascript:void(0);" onclick="directtv9()" data-role="button" data-inline="true" data-mini="true">9</a>       
  397.         <a href="javascript:void(0);" onclick="directtv0()" data-role="button" data-inline="true" data-mini="true">0</a>
  398.         </div>
  399.  
  400. </div>
  401.         <div data-role="collapsible">
  402.         <h3>Mac Mini</h3>
  403. <a href="MobileMouse://" data-role="button">Open Mobile Mouse</a>
  404.  
  405.         <div class="ui-grid-a">
  406.         <div class="ui-block-a"><a href="javascript:void(0);" onclick="appleplay()" data-mini="true" data-role="button">Play / Pause</a></div>
  407.         <div class="ui-block-b"><a href="javascript:void(0);" onclick="applemenu()" data-mini="true" data-role="button">Menu</a></div>
  408.         <div class="ui-block-a"><a href="javascript:void(0);" onclick="appleprevious()" data-mini="true" data-role="button">Previous</a></div>
  409.         <div class="ui-block-b"><a href="javascript:void(0);" onclick="applenext()" data-mini="true" data-role="button">Next</a></div>
  410.         </div>
  411.         </div>
  412.  
  413.  </body>
  414.  </html>
  415.  
  416.  

Here is the Arduino code. This is used to receive the signal from the web server and interpret what IR signal to send.

  1.  
  2. #include <SPI.h>
  3. #include <Ethernet.h>
  4. #include <IRremote.h>
  5. IRsend irsend;
  6. #include <string.h>
  7.  
  8. byte mac[] = {
  9.   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  10. IPAddress ip(192,168,0,9);
  11.  
  12. EthernetServer server(80);
  13. String command="";
  14. char charBuf[300];
  15. char c;
  16. int i=0;
  17. int index=0;
  18. unsigned int angle[300];
  19. char delimiters[] = ",";
  20. char* valPosition;
  21.  
  22. void setup() {
  23.  
  24.  // Open serial communications and wait for port to open:
  25.   Serial.begin(9600);
  26.    while (!Serial) {
  27.     ; // wait for serial port to connect. Needed for Leonardo only
  28.   }
  29.   Ethernet.begin(mac, ip);
  30.   server.begin();
  31.   Serial.print("server is at ");
  32.   Serial.println(Ethernet.localIP());
  33. }
  34.  
  35.  
  36.  
  37. void loop() {
  38.  
  39.   EthernetClient client = server.available();
  40.   if (client) {
  41.       while (client.connected()) {
  42.       while (client.available()) {
  43.         client.read();
  44.  
  45.         for(int i=0; i<4; i++) //This removes the unneeded data before the command
  46.             {
  47.                client.read();
  48.             }
  49.  
  50.           client.read(); // removes the first / in the argument
  51.  
  52.           while ( c != '\n' && c != '/') // This removes everything from the header execept the arguments
  53.           {
  54.              c = client.read();
  55.              charBuf[index++] = c;
  56.              Serial.print(c);  
  57.           }
  58.  
  59.           charBuf[index]=' ';//This removes the second / at the end of the argument
  60.  
  61.           valPosition = strtok(charBuf, delimiters); //fist run of strtok
  62.  
  63.           while(valPosition !=NULL){ //converts all numbers between commas into int
  64.             angle[i] = atoi(valPosition);
  65.             valPosition = strtok(NULL, delimiters);
  66.             i++;
  67.           }
  68.  
  69.           irsend.sendRaw(angle,68,38); // sends infred command
  70.  
  71.           index=0; // resets variables so universal remote buttons can be pushed again
  72.           c=' ';
  73.           i=0;
  74.  
  75.           delay(1);
  76.           client.stop();
  77.       }    
  78.       delay(1);
  79.       client.stop();
  80.       Serial.println("client disonnected");
  81.     }
  82.   }
  83. }
  84.  

Here is the code to decode what signals your remotes are putting out.

  1.  
  2. /*
  3.  * IRremote: IRrecvDump - dump details of IR codes with IRrecv
  4.  * An IR detector/demodulator must be connected to the input RECV_PIN.
  5.  * Version 0.1 July, 2009
  6.  * Copyright 2009 Ken Shirriff
  7.  * http://arcfn.com
  8.  */
  9.  
  10. #include <IRremote.h>
  11.  
  12. int RECV_PIN = 11;
  13.  
  14. IRrecv irrecv(RECV_PIN);
  15.  
  16. decode_results results;
  17.  
  18. void setup()
  19. {
  20.   Serial.begin(9600);
  21.   irrecv.enableIRIn(); // Start the receiver
  22. }
  23.  
  24. // Dumps out the decode_results structure.
  25. // Call this after IRrecv::decode()
  26. // void * to work around compiler issue
  27. //void dump(void *v) {
  28. //  decode_results *results = (decode_results *)v
  29. void dump(decode_results *results) {
  30.   int count = results->rawlen;
  31.   if (results->decode_type == UNKNOWN) {
  32.     Serial.println("Could not decode message");
  33.   }
  34.   else {
  35.     if (results->decode_type == NEC) {
  36.       Serial.print("Decoded NEC: ");
  37.     }
  38.     else if (results->decode_type == SONY) {
  39.       Serial.print("Decoded SONY: ");
  40.     }
  41.     else if (results->decode_type == RC5) {
  42.       Serial.print("Decoded RC5: ");
  43.     }
  44.     else if (results->decode_type == RC6) {
  45.       Serial.print("Decoded RC6: ");
  46.     }
  47.     Serial.print(results->value, HEX);
  48.     Serial.print(" (");
  49.     Serial.print(results->bits, DEC);
  50.     Serial.println(" bits)");
  51.   }
  52.   Serial.print("Raw (");
  53.   Serial.print(count, DEC);
  54.   Serial.print("): ");
  55.  
  56.   for (int i = 0; i < count; i++) {
  57.     if ((i % 2) == 1) {
  58.       Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
  59.     }
  60.     else {
  61.       Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
  62.     }
  63.     Serial.print(" ");
  64.   }
  65.   Serial.println("");
  66. }
  67.  
  68.  
  69. void loop() {
  70.   if (irrecv.decode(&results)) {
  71.     Serial.println(results.value, HEX);
  72.     dump(&results);
  73.     irrecv.resume(); // Receive the next value
  74.   }
  75. }
  76.  

Feel free to PM me @ andyboutte with any questions.

Here are some websites that were helpful in putting this project together:

http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html http://www.zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ http://lirc.sourceforge.net/remotes/ http://arduinostuff.blogspot.com/search?q=infrared

Share