arduino as computer to infrared interface

I have
arduino uno rev 3
seeedstudio ethernet shield
gsm shield
sd card shield
3 pin infrared receivers
2 pin infrared leds

I'm currently attempting to setup arduino as a LAN based mini server witht the following functions:
initiate receive ready state
receive a pulse secuence
transmit LED secuence to an infrared LED
return to a receive ready state and
indicate status or value of inputs and tranmit hia http / html page

I plan to record all of my remote controls with iranalyzer
then create and edit macro secuences with the computer
and finally send the secuence via ethernet or WIFI to ethernet router which sends to arduino

P.S. i would also like to configure the hardware software to receive IR signals from universal remotes with hard-wired buttons or soft virtual buttons such that the signal triggers an action or script on the computer for example a macro could be created on the universal remote that sends an ir signal to the cable set- top box to turn on and to change channel, a signal to the tv to turn on, a signal to the computer to record the video feed. this would allow me to create a homebrewed DIY Digital video recorder like tivo.

I'm not sure what your question is...

But if its ... Is this possible.

I think the answer is Yes you could build a system to do this.

I'm sorry I did not provide details or references.

I would like to use the ardumote http://www.samratamin.com/Ardumote.html sample sketch as a basis but instead of parsing the UDP packet for high or low signals or PWM signals I want the arduino to simply receive a series of 1s and 0s and light up the IR LED accordingly. I want the computer to initiate the UDP packet to the arduino. This will allow me to create a full blown LAMP (arduino will not be host to Linux apache mysql and php - LAMP) server that will host a local intranet access only web page with a set of mobile or desktop menus that recreate the possible soft buttons on the ardumote but on the server instead of on the ardumote app.

In this setup the arduino's only assigned functions will be to receive IR signals and transmit them to the LAMP server for parsing and receive UDP packets ready for IR transmission in other words it will act as an input and output of IR signals and relay the input to the computer via LAN not via USB. the arduino will not save the IR command or their pulse equivalent.

the sketch files I would like to combine are
first Ardumote's sample sketch and then the iranalyzer

#include <SPI.h>         // for Arduino later than ver 0018
//#include <EthernetUdp.h>   // UDP library from bjoern@cs.stanford.edu
#include <Ethernet.h>
         
                         // source:  http://code.google.com/p/arduino/source/browse/trunk/libraries/?r=1094#libraries%2FEthernet 


//////////  NETWORK INFO  ////////////////

byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };  //Set your Ethernet Shield's MAC address here - make sure you replace the ZZs with your shield's values!
byte ip[] = { 192,168,1,20 };    // Set your shield's desired IP address here - check your network for configuration details
//byte gateway[] = { 192,168,1,1 };   //if you need to set a gateway IP
//byte subnet[] = { 255,255,255,0 };    // Change this to your subnet address
  
unsigned int localPort = 7777;      // local port to listen on (set this the same as Port # on Ardumote Params Screen)


IPAddress iPhoneIP(192, 168, 1, 26);  //Set the iPhone/iPod/iPad's IP address to send messages back to Ardumote...
unsigned int iPhonePort = 7777;      //Set the Port # of the message table you configured in Ardumote (default is 7777)...


///////////////////////////////////////////


///////// Pin Assignments /////////////////

int LED_Pin = 6;  //Set LED_Pin to Pin 6 - Place an LED on Pin 6 of your ethernet shield for testing this code

///////////////////////////////////////////



///////////////// UDP Variables  ////////////////// 

// the next two variables are set when a packet is received
//byte remoteIp[4];          // holds received packet's originating IP
//unsigned int  remotePort;   // holds received packet's originating port

// buffers for receiving and sending data
char packBuff[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,

/////////////////////////////////////////////////


EthernetUDP Udp;


void setup() {
  
  // More info on Ethernet on Arduino's website:  http://arduino.cc/en/Reference/EthernetBegin
  // start the Ethernet and UDP:
  Ethernet.begin(mac,ip);   // If you don't need to set your default gateway or subnet manually, use this
//  Ethernet.begin(mac,ip,gateway,subnet);  // Use this line instead if you've manually set all the parameters
  
  
  Udp.begin(localPort);    //Setup UDP socket on port defined earlier

  Serial.begin(9600);    //Start Serial Communications with PC
  
  pinMode(LED_Pin,OUTPUT);    //Designate pin 6 as Output Pin

  

}

void loop() 
{

  
  
  int pwmVal;    // Integer that will hold our PWM values for later use
  
  
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket(); // note that this includes the UDP header
  if(packetSize)
  {
    packetSize = packetSize - 8;      // subtract the 8 byte header
    Serial.print("Packet size: ");
    Serial.println(packetSize);

    // read the packet into packetBuffer and get the senders IP addr and port number
    Udp.read(packBuff,UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Message: ");
    Serial.println(packBuff);

  

 
 /* PWM - If we move a slider on Ardumote, it sends in a 3 digit value attached to the message of the slider.
 
     For example, if your message is set to be "PWM" and your slider is halfway set (slider value is 127),
     then your actual sent message will be received as "PWM127".  Therefore, to set the Pin's PWM value, you simply
     extract the last 3 digits of your message and use that as your PWM value (see below):
     
  */
    
    // Assuming our packBuff's contents at index values 3-5 are our PWM values, you can convert them to an int using this:
  
     pwmVal = (packBuff[3] - '0')*100 + (packBuff[4] - '0')*10 + (packBuff[5] - '0');    //Get PWMXXX message, and use XXX to set an int between 0 and 255.
 
 //////////////////////// Pin 6 (LED_Pin) /////////////////////////////////////       
        
     if (packBuff[0] = 'P' && packBuff[1]=='W' && packBuff[2]=='M')  // Wait for "PWMXXX" and use XXX as value for PWM 
    {

      
      analogWrite(LED_Pin,pwmVal);    //Set LED_Pin to PWM Value
      
      Serial.println("PWM on Pin 6");    //Write notification  
    

    }

    else if (packBuff[0] = 'P' && packBuff[1]=='6' && packBuff[2]=='H')  // If we get the message "P6H", then set LED_Pin (6) HIGH
    {
      
      digitalWrite(LED_Pin,HIGH);    //Turn on LED_Pin
  
      Serial.println("LED ON");    //Write notification 
  
      Udp.beginPacket(iPhoneIP,iPhonePort);
      Udp.write("LED 6 is ON");    // Send Message back to iPhone
      Udp.endPacket();
  
  

    }
    
     
    
    else if (packBuff[0] = 'P' && packBuff[1]=='6' && packBuff[2]=='L')  // If we get the message "P6L", then set LED_Pin (6) LOW
    {
      
      digitalWrite(LED_Pin,LOW);    //Turn off LED_Pin
  
      Serial.println("LED OFF");    //Write notification 
      
      Udp.beginPacket(iPhoneIP, iPhonePort);
      Udp.write("LED 6 is OFF");    // Send Message back to iPhone
      Udp.endPacket();
      
    }
  }
  delay(20);
}

Are the IR signals required to match some existing device or are you free to design your own protocol? For example do you need to produce a 38kHz carrier signal?

I suspect it would make more sense to have sufficient "intelligence" in the Arduino that it can receive bytes of data from the server and convert them into IR signals and convert received IR signals into bytes of data rather than trying to send a stream of raw 1s and 0s.

...R

Wow wow, hold your horses. Too many things! Arduino can do ALL of that, but you need a realistic plan to get all that programmed. I recommend this library for IR:

I've used it with wonderful results. It will decode button pushes and return the sequences.

Leave the ethernet part alone. Just do decode test samples to make sure your hardware is working. Not all IR remote are modulated at 38KHz, some at say 40KHz. Find out which remote control you can read with the sample code first see if you are happy.

Once you get enough experience, you can separately make a web server (plenty code samples) on your ethernet shield and hook up the IR part to the ethernet. Try to separate them as much as you can.

Robin2:
Are the IR signals required to match some existing device or are you free to design your own protocol? For example do you need to produce a 38kHz carrier signal?

I suspect it would make more sense to have sufficient "intelligence" in the Arduino that it can receive bytes of data from the server and convert them into IR signals and convert received IR signals into bytes of data rather than trying to send a stream of raw 1s and 0s.

...R

A little of both to your question of "Ir signals required to match some existing device or are free to design your own protocol?"
the reason being that for the Receive2computer component the computer will parse the IR signal so as to determine what actions to take. However on the computer2Transmitter component the device receiving the IR signal will be a TV, DVD player, a set-top box etc.

liudr:
Wow wow, hold your horses. Too many things! Arduino can do ALL of that, but you need a realistic plan to get all that programmed. I recommend this library for IR:

GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols

I've used it with wonderful results. It will decode button pushes and return the sequences.

Leave the ethernet part alone. Just do decode test samples to make sure your hardware is working. Not all IR remote are modulated at 38KHz, some at say 40KHz. Find out which remote control you can read with the sample code first see if you are happy.

Once you get enough experience, you can separately make a web server (plenty code samples) on your ethernet shield and hook up the IR part to the ethernet. Try to separate them as much as you can.

I am planning to use the IRremote library by ken shirriff.

It is possible to do this.

However, you will have to receive all of the data for each IR signal, before you start sending it - as otherwise you would probably have network delays resulting on gaps in the middle of each signal. If you are only using relatively common IR signals, there is a good change that the IRLib or IRremote libraries would make this easier for you. For example, an NEC IR signal is typicall only 32 bits. However, if you want to send RAW signal timings you will quickly run out of SRAM on most Arduinos.

If you want to get into IR macros(timed sequences of IR signals)....more issues....

what I would like to do is for example

press_play on remote_control_1
signal received by arduino and decoded by IRremote library
a unique identifier for Button=play is sent to HTPC namely XBMC, such that the media center server connected to the TV starts to play the last selection.
the arduino will wait until the IR signal ceases and returns to normal state then
if Photoresistor detects zero light from tv turn_on signal is sent via IR_LED such that the TV turns on and after a delay suficient for the TV to turn on switch_to_HDMI signal is sent via IR_LED
else if Photoresistor detects light from TV then just switch_to_HDMI signal is sent via IR_LED such that the tv changes it's input to HDMI (because the HTPC will be connected through HDMI)

this entire secuence is initiated with one button

Many modern TVs have what are referred to as discrete codes that are not available on the standard remotes.

So it may be possible to find a code for your TV, which only turns on the TV (If it is already on -> no harm done). The power button on most remotes toggle the on/off status.

If you can decode your signals using the library, just stepping thru the unused values may reveal any 'discrete' codes.

If you could ID that code it would save you the hassle of a phototransistor.

Another way of detecting on - if you have USB port on the back or side, just get a usb splitter cable and use one end to detect if 5V is present or not. Similar approaches could be taken to video out ports etc.

the main point I was trying to make is that one button corresponds to multiple actions on multiple devices some of which have Infrared Receivers others will be connected to the computer and subsecuently the arduino's pin assigned to an IR receiver. For instance I would like to create soft buttons on the remote control (remote control equals the voomote zapper dongle for iphone) that the IR signal gets picked up by the arduino, decoded and correspoinds to triggers for TV (on, off, volume up, volume down, change input) or DVD (play, pause,eject) or DVR (play, pause, record) or HTPC or HomeAutomation (dimmer -> lights or lights on or off, fan speed control) etc, etc.