(SKU:RB-03T004)IR Transmitter Module

From ALSRobot-Wki
Jump to: navigation, search
3232.jpg

Contents

overview

Because of the use of the cable in the long-distance transmission process may lead to the transmission of data errors. In 2010 the newly launched the IR&LED module a Arduino compatible infrared emission sensor, through to the Arduino is programmed to emit a 38kHz modulated signal, can adapt to the market a variety of infrared receiving head to IR receiver module 38kHz infrared receiving sensor can receive, so as to realize the wireless infrared communication.

Technical parameters and performance

  1. supply voltage: 5V
  2. working environment: -25~+85 C
  3. storage temperature: -30~+100 degrees
  4. wavelength: 940nm
  5. module size: 13.7mm * 27.8mm
  6. weight: 1g
3232-2.jpg

using method

Pin definition

The definition of the sensor pin

  • S: output signal
  • +: power supply (VCC)
    (GND)

Connect Icon

3232-3.jpg

Application Routine

We use the Arduino controller to do a test, to use the hardware device is as follows:

  1. controller Arduino * 2

The Arduino sensor # expansion board * 2

  1. infrared emission module and infrared receiver module * 1 * 1
  2. potentiometer module * 1 and LED * 1 light emitting module
  3. general 3P sensor cable * 4
  4. USB data communication line x 2
3232-4.jpg
as shown in the figure, the use of sensor cable to connect the digital potentiometer module is connected to the expansion board part of the Arduino sensor emission analog port 0, an infrared emission head connected to the Arduino sensor expansion board 2. Then use the sensor cable to connect the infrared emission head is connected to the receiving part of the Arduino sensor expansion board of the digital port 2, LED light-emitting module is connected to the Arduino sensor expanded plate number nine on.
will send a portion of code compiled downloaded to as the transmission part of the Arduino, will receive part of the code to compile and download to as receiving part of the Arduino, can be in serial assistant window shows the received current value (Note: serial assistant baud rate transferred to 115200).

Sample code

Part program:

#define ADD 0x00 
int IR_S = 2;    
int a; 
void setup() 
{ 
 	 pinMode(IR_S, OUTPUT);  
 	 Serial.begin(115200); 
}
void loop() 
{ 
    uint8_t dat,temp;   
{    
      a=analogRead(0); 
      temp =a/4; 
      Serial.println(temp,DEC );
      IR_Send38KHZ(280,1); 
      IR_Send38KHZ(140,0);
     
      IR_Sendcode(ADD);
      dat=~ADD; 
      IR_Sendcode(dat);
      IR_Sendcode(temp);
      dat=~temp; 
      IR_Sendcode(dat);
     
      IR_Send38KHZ(21,1);
    } 
    delay(200); 
}  
 
void IR_Send38KHZ(int x,int y)  
{  
 for(int i=0;i<x;i++)//15=386US 
   {  
       if(y==1) 
        { 
      		digitalWrite(IR_S,1); 
           delayMicroseconds(9); 
           digitalWrite(IR_S,0); 
           delayMicroseconds(9); 
        } 
       else  
        { 
           digitalWrite(IR_S,0); 
           delayMicroseconds(20); 
        } 
   }                                                            
} 

void IR_Sendcode(uint8_t x)   
{ 
    for(int i=0;i<8;i++) 
    { 
       if((x&0x01)==0x01) 
        { 
            IR_Send38KHZ(23,1); 
            IR_Send38KHZ(64,0);              
        } 
        else  
        { 
            IR_Send38KHZ(23,1); 
            IR_Send38KHZ(21,0);   
        } 
        x=x>>1; 
     }   
} 
this code is the function from the analog port 0 read potentiometer values, and through the infrared emission head will send out the numerical reading.

Receiving part program:

#define IR_LED  2   
#define MAX  128 
#define MICRO_STEP  10 
#define IDLE_PULSE  4000 
unsigned long pulses[MAX]; 
unsigned char IRCOM[7]; 
unsigned long z; 
int w; 
byte f=B00000000;  
int n; 
int ledpin=9;  
void setup() 
{ 
  pinMode(IR_LED, INPUT); 
  Serial.begin(115200); 
  pinMode(ledpin,OUTPUT); 
} 
                                                             
void loop() 
{   
  if( digitalRead(IR_LED) == LOW) 
  { 
     
        int count = 0; 
        int exit = 0; 
    while(!exit) 
    { 
      while( digitalRead(IR_LED) == LOW ) 
         delayMic roseconds(MICRO_STEP); 
      unsigned long start = micros(); 
      int max_high = 0; 
      while( digitalRead(IR_LED) == HIGH ) 
      { 
        delayMic roseconds(MICRO_STEP); 
        max_high += MICRO_STEP; 
        if( max_high > IDLE_PULSE ) 
        { 
          exit = 1; 
          break; 
        }
      }
      unsigned long duration = micros() - start;
      pulses[count++] = duration;
    }
    for(int i=3; i<4; i++) 
    { 
      for(int j=0;j<8;j++) 
      { 
        if(pulses[ i*8+j+1] < IDLE_PULSE) 
         { 
            IRCOM[i]=IRCOM [i] >> 1;            
            if((pulses[i*8+j+1])>1000) 
               {IRCOM[i] = IRCOM[i] | 0x80;}             
         } 
       z= pulses[i*8+j+1]; 
 /***************************************************/ 
                                                                       
 /***************************************************/   
       if(z<800) 
          w=10000000;   
       else 
          w=00000000;   
       f=f>>1;          
       f=f+w;       
 /***************************************************/ 
     } 
    } 
   n=int(f); 
   Serial.print(n); 
   analogWrite(ledpin,n); 
  } 
} 
this part of the code function is through the infrared receiving head receives the value sent in part to send the potentiometer to control LED brightness changes through the serial port assistant shows the current value received. As shown in the diagram below the left serial assistant (serial number: 117) display is to send the infrared part of the sending out of the potentiometer values, the right serial assistant (serial number: 88) display is received by the infrared receiving part numerical.
3232-5.jpg


Product recommendation

Buy address:IR Transmitter Module

Personal tools
Namespaces

Variants
Actions
Navigation
Tools