(SKU:RB-02S002)Mini IR Line Tracking Sensor

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

Contents

overview

It is designed for line sensing applications and comprised of two parts - an IR emitting LED and an IR sensitive phototransistor. It detects white and black color, and it outputs via TTL signal, so the robot can reliably follow a black line on a white background, or vice versa. You can even combine several sensors to meet your specific requirements.

Technical parameters and performance

  1. Operation voltage: +5V
  2. Operation current: <15mA
  3. Operation temperature: -10°c-+70°c
  4. I/O interface: 3 coil interface (+5V/GND/TS)
  5. Output level: TTL level (Use low level to track black line and high level to track white line)
  6. Fixed aperture: 3mm
  7. Feedback indicator: Red
  8. Dimension: 12mm × 35mm
  9. Weight:2 g

using method

Pin definition

The sensor pin is defined as S: output signal +: power (VCC) -: (GND)

Mini-2.jpg

Connect Icon

What123.jpg



Sample code

int xunxianPin = 2;
int ledPin =  13;     
int buttonState = 0;        
void setup() {
  pinMode(ledPin, OUTPUT);      
  pinMode(xunxianPin, INPUT);     
}

void loop(){
  buttonState = digitalRead(xunxianPin);
  if (buttonState == LOW) {       
    digitalWrite(ledPin, HIGH);  
  } 
  else {
    digitalWrite(ledPin, LOW); 
  }
}

Program effect

  1. find Zhang Baizhi, drawing root black lines on white paper (about 1cm wide), or with black electrical tape stick in the white paper;
  2. module according to the wiring diagram of connected line sensor module, do not take the wrong;
  3. will find line module of infrared probe black line alignment, height 1 centimeter or so, when the indicator lamp, a corresponding output (s) TTL outputs low level;
  4. similarly, seeking line module of infrared probe is aligned with a blank sheet of paper, the height of 1 cm or so, when the indicator light, corresponding output (s) TTL outputs high level;

Application Routine

Test of Mini infrared sensor We use the Arduino controller and 2WD car to do the test, to use the hardware device is as follows:

  1. controller Arduino * 1
  2. The Arduino sensor expansion board * 1
  3. car 2WD * 1
  4. line x 3 Mini infrared sensor
  5. sensor bracket * 1
  6. sensor connecting line x 3
  7. DuPont line number
  8. USB data communication line x 1

Sample code

int pinI1=8;//定义I1接口
int pinI2=9;//定义I2接口
int speedpin=11;//定义EA(PWM调速)接口
int pinI3=6;//定义I3接口
int pinI4=7;//定义I4接口
int speedpin1=10;//定义EB(PWM调速)接口
int IRR=3;//定义右侧寻线传感器接口
int IRM=4;//定义中间寻线传感器接口
int IRL=5;//定义左侧寻线传感器接口
void setup()
{
pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpin,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpin1,OUTPUT);
  pinMode(IRR,INPUT);
  pinMode(IRM,INPUT);
  pinMode(IRL,INPUT);
}
void advance()//前进
{
     analogWrite(speedpin,100);//输入模拟值进行设定速度
     analogWrite(speedpin1,100);
digitalWrite(pinI4,LOW);//使直流电机(右)逆时针转
     digitalWrite(pinI3,HIGH);
     digitalWrite(pinI1,LOW);//使直流电机(左)顺时针转
     digitalWrite(pinI2,HIGH);
}
void right()//右转
{
     analogWrite(speedpin,60);//输入模拟值进行设定速度
     analogWrite(speedpin1,60);
     digitalWrite(pinI4,HIGH);//使直流电机(右)顺时针转
     digitalWrite(pinI3,LOW);
     digitalWrite(pinI1,LOW);//使直流电机(左)顺时针转
     digitalWrite(pinI2,HIGH);
}
void left()//左转
{
     analogWrite(speedpin,60);//输入模拟值进行设定速度
     analogWrite(speedpin1,60);
     digitalWrite(pinI4,LOW);//使直流电机(右)逆时针转
     digitalWrite(pinI3,HIGH);
     digitalWrite(pinI1,HIGH);//使直流电机(左)逆时针转
     digitalWrite(pinI2,LOW);
}
void stop()//停止
{
     digitalWrite(pinI4,HIGH);//使直流电机(右)制动
     digitalWrite(pinI3,HIGH);
     digitalWrite(pinI1,HIGH);//使直流电机(左)制动
     digitalWrite(pinI2,HIGH);
}
void loop()
{
    int r,m,l;
    r=digitalRead(IRR);
    m=digitalRead(IRM);
    l=digitalRead(IRL);
    if(l==HIGH &&m==LOW && r==HIGH)
    advance();
    else if(l==LOW && m==HIGH && r==HIGH)
    left();
    else if(l==HIGH && m==HIGH && r==LOW)
    right();
    else stop();
}

Function code is in the middle of the patrol line sensor to detect black line trolley forward, on the left side of the patrol line sensor to detect black line car left, on the right side of the patrol line sensor to detect black line car turn right. Not detected car black line will stop.

Product recommendation

Buy address:Mini IR Line Tracking Sensor

Personal tools
Namespaces

Variants
Actions
Navigation
Tools