Group assignment is here
This week's task is to establish communication between the input devices and the controller.
To solve this problem, I will use the hc-sr501 infrared motion sensor and the servomotor already configured in week 9, which is controlled by the esp32s3 controller.
Whst is HC-SR501 PIR MOTION DETECTOR
HC-SR501 is based on infrared technology, automatic control module, using Germany imported LHI778 probe design, high sensitivity, high reliability, ultra-low-voltage operating mode, widely used in various auto-sensing electrical equipment, especially for battery-powered automatic controlled products.
Specification:
◦ Voltage: 5V – 20V
◦ Power Consumption: 65mA
◦ TTL output: 3.3V, 0V
◦ Lock time: 0.2 sec
◦ Trigger methods: L – disable repeat trigger, H enable repeat trigger
◦ Sensing range: less than 120 degree, within 7 meters
◦ Temperature: – 15 ~ +70
◦ Dimension: 32*24 mm, distance between screw 28mm, M2, Lens dimension in diameter: 23mm
I connect the PIR as follows - power to the 5 V esp output, ground to ground and the control output to pin 2.
Datasheet is here
How to conection PIR for board?
I will add sensor control functions to the already created servo and laser diode control code.
The servo will move when motion is detected by the PIR sensor
You need to be very careful when using the PIR, because if it is not connected correctly, it can completely fail. You also need to adjust the sensitivity. At first, the sensor responded only to the movement of large objects. You also need to consider the delay between sensing the sensor and moving the servo.
Sketch is here