Pages: [1]   Go Down
Author Topic: IR Library Help  (Read 1053 times)
0 Members and 1 Guest are viewing this topic.
NE PA
Offline Offline
Full Member
***
Karma: 5
Posts: 156
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been banging my head over this for the last couple of days but can't get it working. I downloaded the IR library and have been able to use the IRRecvDump file to get the raw data from my IR receiver (from a Vizio TV remote). However I cannot for the life of me figure out how to get the raw data to output the code back to my Vizio TV.

Here is some info:
I have the IR LED (940nm from Radioshack) wired from GND to the cathode, anode to a resistor to pin 3. I was able to use Adafruit's code to get my Nikon camera to flash from across the room so I don't think wiring is the problem.

My code (actually Ken Shirriff's code slightly modified for raw output)
Code:
/*
 * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */
 
#include <IRremote.h>
 
IRsend irsend;
 
// just added my own array for the raw signal
unsigned int irCode[68] = {4450,4500,550,1700,500,1750,500,1750,500,600,550,600,500,600,550,600,500,600,550,1700,550,1700,550,1700,500,600,550,600,500,600,550,600,500,650,500,600,550,1700,500,650,500,600,550,600,500,600,550,600,500,600,550,1700,550,600,500,1700,550,1700,550,1700,550,1700,500,1750,500,1750,500};
 
void setup()
{
   Serial.begin(9600);
}
 
void loop() {
 
      // altered the code just to send/test my raw code
      irsend.sendRaw(irCode,68,38);
      delay(100);
 
}

I have looked through a number of tutorials and some recommended removing the first raw number or changing the frequency (38) to 40. Neither helped.

Is there any chance the Vizio TV uses a different frequency than 38khz? Or any other ideas?
Logged


Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The quick advice I can give you is 2 things.

1) Put the delay out to 1000 milliseconds.  You might be running it too fast.

2) Use a camera to view the IR LED to see if it is turning on.  Even though you can't see it, the camera will see it.

Did you try running a real Vizio command?  Both Vizio TVs I have use 20DF10EF as the on/off command.
Logged

NE PA
Offline Offline
Full Member
***
Karma: 5
Posts: 156
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I did check with a camera to see if the LED was blinking and it was. I tried a few commands with the sendNEC function and it didnt work. I will try your code when I get a chance though. Is this the syntax you used? Thanks for the help.

Code:
irsend.sendNEC(0x20DF10EF,32);
Logged


Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have never sent any commands, I only decode them. 
But yes, it does send a NEC Protocol code and your line of code looks correct.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I downloaded Ken Shirriff's IR library,

question:


I simply want to use Pin 5 for the IR emitter on my Arduino Uno.
How do I change and use another PWM output pin other than Pin 3?


Any other PWM pin 5,6,9,10,11 doesn't work either... except pin 3.


Do I have to modify some code in the library file: IRremote.h ? 


#include <IRremote.h>

#define PIN_IR 3   // I want to use Pin 5 or another PWM output
#define PIN_DETECT 2
#define PIN_STATUS 13


IRsend irsend;
void setup()
{
  pinMode(PIN_DETECT, INPUT);
  pinMode(PIN_STATUS, OUTPUT);
  irsend.enableIROut(38);
  irsend.mark(0);
}

void loop() {
  digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT));
}





Any ideas?
Logged

Arduino...addicted

NE PA
Offline Offline
Full Member
***
Karma: 5
Posts: 156
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I can't explain it, but now it works. I did another raw dump from the remote using the IRrecvDump sketch, something I did multiple times last night, and the code was slightly different this time and it worked. Why it was different this time I have no idea.
Logged


NE PA
Offline Offline
Full Member
***
Karma: 5
Posts: 156
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I downloaded Ken Shirriff's IR library,

question:


I simply want to use Pin 5 for the IR emitter on my Arduino Uno.
How do I change and use another PWM output pin other than Pin 3?


Any ideas?

You should get in the habit of creating your own threads. Most people don't like others asking questions in their threads, it is considered thread hijacking.

I recently read that because of the way the arduino timers are setup it would take a good bit of modifying the code to change the pin. Basically it isn't worth it. With that said, why do you need to?
« Last Edit: January 20, 2013, 04:26:36 am by Quick5pnt0 » Logged


Upstate NY
Offline Offline
Full Member
***
Karma: 2
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I can't explain it, but now it works. I did another raw dump from the remote using the IRrecvDump sketch, something I did multiple times last night, and the code was slightly different this time and it worked. Why it was different this time I have no idea.
Congats - you fixed it.  Good luck!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quick5pnt0 : thread hijacking...was sincerely unaware of this, thanks for letting me know.  smiley-red

I'm using the 5940 library in the same sketch but pin 3 is reserved for it, just wanted to use the IR Remote library to produce a 38khz in the same sketch. Upon more research, i'm realizing that using an external 555 timer circuit to produce a 38khz signal for an IR Emitter is likely a better option.

Thanks for replying! smiley
Logged

Arduino...addicted

Pages: [1]   Go Up
Jump to: