能实现无接触远距离测量、速度快、精度高、量程大、抗光、电干扰能力强,应用于各种长距离、大区域安防检测、工业自动化光电信号检测等。
序号 |
arduino引脚 |
模块引脚 |
1 |
D2 |
发射管S |
2 |
5V |
发射管Vcc |
3 |
GND |
发射管GND |
4 |
D3 |
接收管S |
5 |
5V |
接收管Vcc |
6 |
GND |
接收管GND |
1 int lasersend = 2; 2 3 int laserrev = 3; 4 5 int revled = 13; 6 7 int val; 8 9 void setup() { 10 11 // put your setup code here, to run once: 12 13 pinMode(lasersend, OUTPUT); 14 15 pinMode(laserrev, INPUT); 16 17 pinMode(revled, OUTPUT); 18 19 digitalWrite(lasersend; HIGH); 20 21 } 22 23 24 25 void loop() { 26 27 // put your main code here, to run repeatedly: 28 29 val = digitalRead(laserrev); 30 31 if (val == HIGH) 32 33 { 34 35 digitalWrite(revled, HIGH); 36 37 } 38 39 else { 40 41 digitalWrite(revled, LOW); 42 43 } 44 45 }