TOP

Grove - Infrared Emitter

From Wiki 来自痴汉的爱
Jump to: navigation, search
Grove - Infrared Emitter.jpg

[中文]



Contents

Introduction

The Infrared Emitter is used to transmit infrared signals through an infrared LED, while there is an Infrared receiver to get the signals on the other side . An infrared LED is like any other LED, with its color centered around 940nm. We can not only use the emitter to transmit data or commands, but also to emulate remotes to control your home appliance using an Arduino. The Infrared Emitter can transmit signals reliable up to 10 meters. Beyond 10 meters, the receiver may not get the signals.
Model: WLS12148P




Specification

  • Voltage: 3.3-5V
  • Distance:10m




Demonstration

The Grove - Infrared Emitter can send data while Grove- Infrared Receiver will receive them.

  • Connect the Grove - Infrared Emitter to D3.
  • Connect the Grove - Infrared Receiver to A4.
IR SendRev.jpg
  • Download the library IR Send and Receiver Library, Unzip it into the libraries file of Arduino IDE by the path: ..\arduino-1.0\libraries.
  • Open the code directly by the path:File -> Example ->IRSendRev->sendTest.
//**************
//IR sent demo v1.0
//Connect the IR sent pins to D3 for this demo
//By:http://www.seeedstudio.com/
//******************************
#include <IRSendRev.h>

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);
}
  • Open the code directly by the path:File -> Example ->IRSendRev->revTest.
 //**************
//IR receive demo v1.0
//Connect the IR sent pins to A4 for this demo
//By:http://www.seeedstudio.com/
//******************************
#include <IRSendRev.h>
//#include <IRSendRevInt.h>

void setup()
{
    Serial.begin(38400);
    IR.Init(A4);
    Serial.println("init over");
}

unsigned char dta[20];

void loop()
{
    if(IR.IsDta())
    {
       // IR.Recv(dta);
        int length= IR.Recv(dta);
        for (int i =0;i<length;i++)
        {
          Serial.print(dta[i]);
          Serial.print("\t");
        }
        Serial.println();
// Very Important:
// the received data are comprised of the trsmission parameters , please refer to 
// the sendTest.ino in the library ;
    }
 }
  • Upload the Code to the receiver arduino.
  • When the Infrared Emitter tube faces the IR receiver tube(the distance of emitter to receiver should be less than 10m), then open the Grove_-_Infrared_Receiver serial port for see information:

IR Send and Receiver.jpg




Resources

Personal tools
Namespaces

Variants
Actions
Navigation
Support
Start here|开始探索
Learn|学习
Product|产品线
Category|分类
Toolbox