IR transmitter & recorder

Thanks everybody for your suggestions - I’ve made some progress and thought it would be good to give an update as it may be a good time to learn from others experience before I make too many more mistakes!

So I looked at the arduino code that I linked to above, but being that I’m new to this I didn’t understand how to port the libraries (.h files ?!) so that they could be included on the core. - I looked for an example but it seems the servo lib is the only one so far (other than maybe LCD) and that has been included by default. The problem here is that I can’t see where I’d put the .h file as I flash the code via the api.

Any way what I could understand was how a function could be written to turn a led on and off, how the core can be powered by AA batteries via the vin port and how a sequence of on’s and off’s could be programmed when a push button is pressed.

So I read the detail on this page: http://www.remotecentral.com/features/irdisp3.htm which explains how a hex code can be converted to a series of burst pairs. These are as I understand it essentially on and offs of the IR led for a specified length of time at a given frequency.

I took the hex code for the channel up function from here: http://www.geekzone.co.nz/forums.asp?topicid=94816

which looks like:

0000 0078 0000 0024 000E 000A 0006 0009 0005 0015 0006 000A 0006 001B 0005 0015 0005 000A 0006 000A 0006 000A 0005 0009 0006 0015 0006 000F 0006 0015 0005 000A 0006 0015 0006 000A 0005 000A 0005 0C35 000E 000A 0006 000A 0005 0015 0006 000A 0006 001B 0005 0015 0006 000A 0006 000A 0006 000A 0005 000A 0006 0015 0006 000F 0006 0015 0005 000A 0006 0015 0006 000A 0005 000A 0006 0C15 

Then used a hex to decimal converter to turn this into a sequence that could be used in the code for the core. - There maybe much more elegant ways of actually converting hex code with the core … which would be nice but I’m not that advanced yet!

http://www.binaryhexconverter.com/hex-to-decimal-converter

/*
 Button
 
 Turns on and off a light emitting diode(LED) connected to digital  
 pin 3, when pressing a pushbutton attached to pin 2. 

*/
// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  3;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int freq = 1 / 36000 ; // which gives value in milliseconds
//int freq = 10 ; // so that we can see it with the human eye for testing (via digital camera)

//functions

void IrOnOff(int x, int y)

{  
    digitalWrite(ledPin, HIGH); // turn LED on
    delay(x * freq);               // Wait for  X microseconds
    digitalWrite(ledPin, LOW); // turn LED off
    delay(y * freq);               // Wait for  Y microseconds
}

void SKYCHUP()
{

IrOnOff(14,10);
IrOnOff(6,9);
IrOnOff(5,21);
IrOnOff(6, 10);
IrOnOff(6,27);
IrOnOff(5, 21);
IrOnOff(5,10);
IrOnOff(6,10);
IrOnOff(6,10);
IrOnOff(5, 21);
IrOnOff(6,21);
IrOnOff(6,15);
IrOnOff(6,21);
IrOnOff(5,10);
IrOnOff(6,21);
IrOnOff(6,10);
IrOnOff(5,10);
IrOnOff(5,3125);
IrOnOff(14,10);
IrOnOff(6,10);
IrOnOff(5,21);
IrOnOff(6,10);
IrOnOff(6,27);
IrOnOff(5,21);
IrOnOff(6,10);
IrOnOff(6,10);
IrOnOff(6,10);
IrOnOff(5,10);
IrOnOff(6,21);
IrOnOff(6,15);
IrOnOff(6,21);
IrOnOff(5,10);
IrOnOff(6,21);
IrOnOff(6,10);
IrOnOff(5,10);
IrOnOff(6,3093);

}

//main code

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop()
{
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) 
  {     
    //IR SEQUENCE HERE
        SKYCHUP();
  } 
  else 
  {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
  }
}

Here is a link to the video so far: http://youtu.be/9HZCocjik8g … unfortunately when I changed the code back to milliseconds it didn’t actually work! - but I think this is to do with the frequency / maybe my understanding of the delay function.

So the current function is getting the delay frequency by taking 1 (second) divided by 36000 the ir frequency derived from the second word in the hex sequence - this gives a result in microseconds I think - but this could be wrong. Basically I’ve spent time here trying to prove that the hardware is working & also that the code written for the Core will conceptually work.

Now I guess more time needed on understanding the logic behind the frequency of pulses and getting one signal to actually work. Then I need to know how many of these functions can be stored in the core ?? i.e channel up channel down etc - with no external storage I presume the capacity is limited?

Also then when I do finally get this bit working & move onto the receiver, how can I monitor the output? - with a classic arduino I assume you could just plug in via usb and monitor the output on the PC? - but with the core running through the API I’m not sure how to do that - especially given that data transmitted back is limited to integers (I read somewhere on here) … lots to think about!

Any suggestions / pointers welcome!

Thanks