Product Introduction #
Photoelectric sensor are commonly used to detect the presence, position, or motion of an object.
It consists of a transmitter, which generates an infrared beam, and a receiver, which receives the infrared beam. When the middle is blocked, the receiver cannot receive the light signal, so as to detect the presence or movement of the object.
Parameter Specification #
Wiring Diagram #
PIR Motion Sensor | UNO |
---|---|
VCC | 5V |
GND | GND |
S | Digital Pin 7 |
Sample Code #
//www.acebott.com
void setup() {
pinMode(7,INPUT);//Set pin 7 to input mode
Serial.begin(9600);//Set baud rate to 9600
}
void loop() {
Serial.println(digitalRead(7));//Read the state of pin 7and print it to the serial monitor
delay(1000);
}
Test Result #
After uploading the code to the controller board, open the serial port monitor of the Arduino IDE and set the baud rate to 9600.
When there is no object blocking the sensor, the sensor returns data 0. When there is an object blocking, the sensor returns data 1.
Related Resources #
Get One Now #
B2B Business: info@acebott.com