Go Down

Topic: IR transmittion (Read 1 time) previous topic - next topic

Gofilord

Hi there,
I used the ladyada's tutorial on IR to recieve the code of my TV remote, that worked out great, and here it is:
Code: [Select]
86, 88,
176, 88,
84, 90,
86, 88,
86, 88,
84, 90,
84, 94,
82, 88,
84, 174,
84, 90,
176, 88,
86, 2394,
86, 88,
176, 88,
86, 92,
88, 82,
92, 82,
86, 88,
86, 88,
92, 82,
92, 166,
92, 82,
182, 82,
86, 2398,
88, 82,
182, 82,
86, 88,
86, 88,
92, 82,
92, 86,
82, 84,
96, 82,
86, 172,
92, 82,
182, 86,
82, 0


Now I have an IR LED and I would like to transmit this sequence with it.
Only problem is that Ladyada did not explain well (at least to me) how to do so, He only gave his personal example using his Apple remote.
Should I copy and pase each and every number to the frame of "PulseIR" and "delay"?
because it will take hours and I bet there is another way to copy and paste everything into a code or something.

Please make it simple, THANKS!

PaulS

Quote
I used the ladyada's tutorial on IR

I'm not hunting for it. Post a link.

Gofilord

Sorry I thought you knew it.
http://www.ladyada.net/learn/sensors/ir.html

Claghorn

I'm working on a fanatical IR remote project. You might be able to dig up useful info and/or code out of my web pages at:

http://home.comcast.net/~tomhorsley/hardware/arduino/aardremote.html

I use the arduino as a low level device I talk to with bluetooth or over USB and have a host system (my linux box or android phone) send commands and get back IR info.
http://home.comcast.net/~tomhorsley/hardware/arduino/arduino.html

Gofilord

Guys, are you suggesting that I will copy each and every number from the sequence in to the figure the website gave? That's just not right.

johnwasser

Put the values in an array as per int IRsignal[] = { // ON, OFF (in 10's of microseconds)
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Gofilord

How does that help me?

johnwasser


How does that help me?


Code: [Select]

for (int i=0; i< pulses, i++)
    {
    pulseIR(IRsignal[2*i] * 10');
    delayMicroseconds(IRsignal[2*i+1] * 10);
    }
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Gofilord

thanks. Where do i put this code, and where do I put the numbers from the remote?

johnwasser


thanks. Where do i put this code, and where do I put the numbers from the remote?


You put the code in the place in your sketch where you want to send the signal.

You put your numbers in the IRsignal array, like they show in the examples you referenced.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Gofilord

I need a complete code that pulses the IR LED according to my numbers. You gave me a segment of the code and told me to put it in what sketch?
and let's say I put them in the array, like this:
Code: [Select]
int IRsignal[] = { // ON, OFF (in 10's of microseconds)
        86, 88,
176, 88,
84, 90,
86, 88,
86, 88,
84, 90,
84, 94,
82, 88,
84, 174,
84, 90,
176, 88,
86, 2394,
86, 88,
176, 88,
86, 92,
88, 82,
92, 82,
86, 88,
86, 88,
92, 82,
92, 166,
92, 82,
182, 82,
86, 2398,
88, 82,
182, 82,
86, 88,
86, 88,
92, 82,
92, 86,
82, 84,
96, 82,
86, 172,
92, 82,
182, 86,
82, 0};


Now it's in the array, how do I combine it with the pulsing code? I'm confused

johnwasser


I need a complete code that pulses the IR LED according to my numbers. You gave me a segment of the code and told me to put it in what sketch?


OK, I'll write the full sketch for you, but you won't learn much that way.
Code: [Select]


// This sketch will send out an arbitrary IR signal

int IRledPin =  13;    // LED connected to digital pin 13

const int pulses = 37;

const int IRsignal[pulses*2] = { // ON, OFF (in 10's of microseconds)
  86, 88,
  176, 88,
  84, 90,
  86, 88,
  86, 88,
  84, 90,
  84, 94,
  82, 88,
  84, 174,
  84, 90,
  176, 88,
  86, 2394,
  86, 88,
  176, 88,
  86, 92,
  88, 82,
  92, 82,
  86, 88,
  86, 88,
  92, 82,
  92, 166,
  92, 82,
  182, 82,
  86, 2398,
  88, 82,
  182, 82,
  86, 88,
  86, 88,
  92, 82,
  92, 86,
  82, 84,
  96, 82,
  86, 172,
  92, 82,
  182, 86,
  82, 0};

// The setup() method runs once, when the sketch starts

void setup()   {               
  // initialize the IR digital pin as an output:
  pinMode(IRledPin, OUTPUT);     

  Serial.begin(9600);
}

void loop()                     
{
  Serial.println("Sending IR signal");

  SendCode(pulses, IRsignal);

  delay(60*1000);  // wait one minute (60 seconds * 1000 milliseconds)
}

// This procedure sends a 38KHz (26 microsecond cycle time) pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
  // we'll count down from the number of microseconds we are told to wait

  cli();  // this turns off any background interrupts

  while (microsecs > 0) {
    // 38 kHz is about 13 microseconds high and 13 microseconds low
    digitalWrite(IRledPin, HIGH);  // this takes about 3 microseconds to happen
    delayMicroseconds(10);         // hang out for 10 microseconds
    digitalWrite(IRledPin, LOW);   // this also takes about 3 microseconds
    delayMicroseconds(10);         // hang out for 10 microseconds

    // so 26 microseconds altogether
    microsecs -= 26;
  }

  sei();  // this turns them back on
}

void SendCode(const int pulses, const int IRsigna[]) {

  for (int i=0; i< pulses; i++)
  {
    pulseIR(IRsignal[2*i] * 10);
    delayMicroseconds(IRsignal[2*i+1] * 10);
  }
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Gofilord

Wow thanks a lot! I think it's easier and more effective to learn out of an exciting code.
Now, Instead of the 60 second delay I want to put a switch and every time I click the switch it will kick the code.
What I need to do is just embed the "button" example instead of the 60*1000 line?

DuaneB

Quote
OK, I'll write the full sketch for you, but you won't learn much that way.


Slow day at work, or just wanted to get it over and done with ?

Duane B
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

Go Up