Home / Wiki / Sensor / Distance
IR Module(swiping card reader)

Introduction

This IR module is used to detect if there’s someone swiping the card, it is mainly consist of reflective sensors include an infrared emitter and an infrared receiver, there are two tubes, the white one is emitter and the other is receiver, the receiver is actually a phototransistor, when it  hasn’t been lighted by the emitter, it is at the off state, when lighted by the emitter, it will be on. We design the circuit by this principle: when there’s nothing between the white and black tube, analog signal will be low, if it is lower than the threshold set by the variable resistance, LM393 will compare it and output digital high. You can connect it to a count circuit and then you can account how many card has been swiped via the IR module.

 

Technical Data

Operating wavelength: 950mm

Operate voltage: DC 3 to 5.5V

Typical voltage: 5V

 

Usage

 

[code]

/*

 * connect IR module's output pin to Catduino Uno's analog pin 5

 */int IRPin=A5;      

void setup() {

pinMode(IRPin, INPUT);  //difine the IRPin as input pin

Serial.begin(9600);    //set serial monitor's baud rate as 9600

}

 

void loop() {

  int value=analogRead(IRPin);  //read IRPin's analog signal

  if(value>128){                //analog signal has been devided into 256 part

   value=1;                    

   /*transfer analog signal to digital signal,

    if value is more than 128, half of 256,

    value will be set as high level.

   */

   Serial.println(value);      //display value via serial monitor

  }

  else{

    value=0;

    Serial.println(value);

   }

   delay(1000);      //delay 1000 μs 

}

[/code]



Resource

Program

Schematic

Datesheet