Sending a remote code through IR

Hello I have been having trouble, probably because I am a noob lol I simply would like to send and ir code through my ir led. So lets say that way I can turn a tv off and on. Could someone please give me an example. :-[

a google search for: arduino ir tv brings up a lot of links that may be of use.

Also be sure to check this guy out:

http://www.tvbgone.com/cfe_tvbg_main.php

Would it be a line like this?

digitalWrite(irled, youcode here);

Would it be a line like this?

digitalWrite(irled, youcode here);

No, I'm sorry, it's a bit more complicated than that. "yourcode here" can, in reality, take only one of two values, HIGH or LOW.

To send a code, you have to send a stream of carefully timed HIGHs and LOWs, and even that is probably an over-simplification. Depending on the remote mfr, the HIGHs could be a short stream of even shorter pulses (modulation).

Sorry, you've got some reading to do. Good news is, there's lots of help and software out there.

Well why is it that I can go to my local radioshack and buy a remote, then I can program the code that is for my tv into it. I dont need to measures pulses lol.

Well why is it that I can go to my local radioshack and buy a remote, then I can program the code that is for my tv into it.

Because someone else has already taken the trouble to program the microcontroller in the RadioShack remote to replay stored codes.

Well why is it that I can go to my local radioshack and buy a remote, then I can program the code that is for my tv into it. I dont need to measures pulses lol.

:o

Lawl.
Well, I’ve got the 38 KHZ Receiver(http://www.radioshack.com/product/index.jsp?productId=2049727) to work with a sample code I found online… And I understand it’s coded for a different remote, so I always get a button 0 Response, but also I get the values in.
I did a search and seen lots of receivers, even some transmitters, but I don’t understand how to implement the values I get in from Serial.print, into a IR Transmitter code.

I kind of understand the values coming in… they’re the microsecond pulses ( I think, lol ), just setting the IR pin high for that amount of time, then low, then the next value… but putting that in code is what’s confusing :smiley:

Any help understanding, or a point in the right direction would be awesome! (I hope I posted in the right area, wasn’t sure if I should start a new thread)
(PS, I’m assuming I can use the Emitter from the Radioshack Emitter/Detector pair, that’s what I’m aiming for, if not let me know please!) (http://www.radioshack.com/product/index.jsp?productId=2049723

Here’s the sample code that I’m using.

int ir_pin = 7;                         //Sensor pin 1 wired through a 220 ohm resistor
int led_pin = 13;                           //"Ready to Receive" flag, not needed but nice
int debug = 1;                           //Serial connection must be started to debug
int start_bit = 2000;                   //Start bit threshold (Microseconds)
int bin_1 = 1000;                           //Binary 1 threshold (Microseconds)
int bin_0 = 400;                             //Binary 0 threshold (Microseconds)


void setup() {
 pinMode(led_pin, OUTPUT);             //This shows when we're ready to receive
 pinMode(ir_pin, INPUT);
 digitalWrite(led_pin, LOW);       //not ready yet
 Serial.begin(9600);
}

void loop() {
 int key = getIRKey();             //Fetch the key
 if (key != -1) {
   Serial.print("Key Recieved: ");
   Serial.println(key);
 }
}


int getIRKey() {
 int data[12];
 digitalWrite(led_pin, HIGH);     //Ok, i'm ready to recieve
 while(pulseIn(ir_pin, LOW) < 2200) { //Wait for a start bit
 }
 data[0] = pulseIn(ir_pin, LOW);       //Start measuring bits, I only want low pulses
 data[1] = pulseIn(ir_pin, LOW);
 data[2] = pulseIn(ir_pin, LOW);
 data[3] = pulseIn(ir_pin, LOW);
 data[4] = pulseIn(ir_pin, LOW);
 data[5] = pulseIn(ir_pin, LOW);
 data[6] = pulseIn(ir_pin, LOW);
 data[7] = pulseIn(ir_pin, LOW);
 data[8] = pulseIn(ir_pin, LOW);
 data[9] = pulseIn(ir_pin, LOW);
 data[10] = pulseIn(ir_pin, LOW);
 data[11] = pulseIn(ir_pin, LOW);
 digitalWrite(led_pin, LOW);

 if(debug == 1) {
   Serial.println("-----");
 }
 for(int i=0;i<=11;i++) {                 //Parse them
   if (debug == 1) {
         Serial.println(data[i]);
   }
   if(data[i] > bin_1) {                 //is it a 1?
       data[i] = 1;
   }  else {
       if(data[i] > bin_0) {           //is it a 0?
         data[i] = 0;
       } else {
        data[i] = 2;                     //Flag the data as invalid; I don't know what it is!
       }
   }
 }

 for(int i=0;i<=11;i++) {                 //Pre-check data for errors
   if(data[i] > 1) {
       return -1;                           //Return -1 on invalid data
   }
 }

 int result = 0;
 int seed = 1;
 for(int i=11;i>=0;i--) {                //Convert bits to integer
   if(data[i] == 1) {
       result += seed;
   }
   seed = seed * 2;
 }

 return result;                             //Return key number
}

It looks like your sketch is a receiver and I think the OP wants to send. You will probably be better off starting your own thread (although this one promises to provide some unintentional humour)

Doh, sorry if I didn't make it clear!-

That's just the sketch I'm using to get IR codes from my remote (hooked up to the 38KHZ Receiver through a 220ohm resistor). I'm looking to turn what I get from that sketch, into a sketch I can use to send those through a Emitter :D

I work things out in my head, and sometimes they don't come out on the keyboard as clear, my apologies :)

I have a psp program called ir shell. It uses hex codes like these http://www.remotecentral.com/cgi-bin/files/rcfiles.cgi?area=pronto&db=discrete&br=dishnetwork&dv=dssreceiver to control devices.

Is there a way I convert these so I can get them the pulse way? for instance 255, 136, 130, 34

I am using this code http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/

Sorry if I sound like I am crazy, but I am new to this