GROVE Infrared Emitter And Receiver code problems

Hello !
I have a problem using this code that i have found on Seeedstudio itself . The basic principle of this circuit is simple. It is to turn on the LED light after it detects the receiver and emitter when it is within range. I need a solution of what code is needed to be added so that it can fucntion properly. as I cannot find a way to output the LED light.

(Infrared receiver's code)
#include <IRSendRev.h>
//#include <IRSendRevInt.h>
int led = 2 ;

void setup()
{
pinMode(led, OUTPUT);
IR.Init(A3);

}

unsigned char dta[20];

void loop()
{
if(IR.IsDta())
{
// IR.Recv(dta);
int length= IR.Recv(dta);
for (int i =0;i<length;i++)
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second

}

(Infrared Emitter's code)

void setup()
{
enableIROut(38);
}
//unsigned char d[] = {9, 90, 91, 11, 31, 4, 1, 2, 3, 4};
unsigned char d[] = {15, 70, 70, 20, 60, 10, 1, 2, 3, 4,5,6,7,8,9,10};
//Very Important:
//the first parameter(15): the data that needs to be sent;
//the next 2 parameter(70,70): the logic high and low duration of "Start";
//the next 2 parameter(20,60): the logic "short" and "long"duration in the communication
// that to say: if "0", the high duration is 20ms and low is 20 ms; while logic "1",
// the high duration is 20 ms and low is 60 ms;
//the next 2 parameter(10): number of data you will sent;
//the next parameter(1, 2, 3, 4,5,6,7,8,9,10): data you will sent ;
void loop()
{
IR.Send(d, 38);//sent the data via 38Kz IR
delay(1000);
}

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

  • Moderator

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

How to use this forum

I'd love to help but I have no idea what this....

It is to turn on the LED light after it detects the receiver and emitter when it is within range.

.... means.

It's not clear to me if there's another ordinary LED you want to turn on, over an above the IR one.

Let's have a schematic then we can see what we're dealing with here. Also provide links to your parts: I Googled for Grove IR but I shouldn't have to do that... maybe I found the wrong one.

did it compile?

Looks like you are missing the library "#include" in the send sketch.

PS: Thats why its always a good idea to post using code tags as already mentioned.