(SKU:RB-03T005)IR Receiver Module

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

Contents

overview

IR is widely used in remoter control. If you have the right decoder, the Arduino project is able to receive command from any IR remote controller with this IR receiver. Well, it will be also easy to make your own IR controller by using IR transmitter.

Technical parameters and performance

  1. Power Supply:5V
  2. Interface:Digital
  3. Modulate Frequency:38Khz
  4. Weight:3g


Pin definition

The sensor pin is defined as

  • S: output signal
  • +: power supply (VCC)
  • -: (GND)
324325-2.jpg

Connect Icon

324325-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. potentiometer module * 1 and LED * 1 light emitting module
  4. USB data communication line x 2
324325-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). Arduino experimental code is as follows.

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
324325-5.jpg


Product recommendation

Buy address:IR Receiver Module

Personal tools
Namespaces

Variants
Actions
Navigation
Tools