Pages: [1]   Go Down
Author Topic: IR transmittion  (Read 1022 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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!
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49451
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I used the ladyada's tutorial on IR
I'm not hunting for it. Post a link.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Delray Beach, FL USA
Offline Offline
Full Member
***
Karma: 0
Posts: 113
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Put the values in an array as per int IRsignal[] = { // ON, OFF (in 10's of microseconds)
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How does that help me?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How does that help me?

Code:
for (int i=0; i< pulses, i++)
    {
    pulseIR(IRsignal[2*i] * 10');
    delayMicroseconds(IRsignal[2*i+1] * 10);
    }
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

// 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);
  }
}
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Pages: [1]   Go Up
Jump to: