|Published (Last):||15 May 2007|
|PDF File Size:||3.71 Mb|
|ePub File Size:||15.34 Mb|
|Price:||Free* [*Free Regsitration Required]|
This code can also be used to control simple relays to turn a bigger light on or off. You can upload the example code with the Arduino IDE. Also adjust the time-delay potentiometer to the lowest value.
Turn it counterclockwise as far as it will go. More info: www. I connected them to Arduino pin 2 and 13 on-board LED. The statement define is used to give a name to a constant value. The compiler will replace any references to this constant with the defined value when the program is compiled. So everywhere you mention pirPin, the compiler will replace it with the value 2 when the program is compiled.
In the setup , we set the pins as input or output with the function pinMode pin,mode. The pirPin is an input and the ledPin is an output. We also begin serial communication at a baud rate of Make sure that the Serial Monitor is also set to Note that I first check the current motionState, this makes sure that the message is only printed once per motion event. Create an alarm system with PIR motion sensor and buzzer With some simple changes, you can create an alarm system with the HC-SR and a piezoelectric buzzer.
You can probably use the buzzer without a resistor this makes it louder , but it will not sound as nice. The code below is mostly the same as the previous example. I only added a function to create the beeping alarm sound. You can change the pitch of the buzzer by changing the input parameter of the alarm duration,frequency function. This takes approximately 1 minute when it is first powered up. Try to eliminate any motion in front of the sensor during this period.
Wind and a light source close to the sensor can cause interference, so try to adjust your setup to avoid this. Also note that you must mount the sensor horizontally, since most motion will happen in the horizontal plane e.
By default, the blocking time is 2. During this time period, the sensor will not detect any motion. When designing a system based on the HC-SR, you will need to take these delay periods into account. I hope you found it useful and informative. If you did, please share it with a friend who also likes electronics and making things! I would love to know what projects you plan on building or have already built with this sensor. If you have any questions, suggestions or if you think that things are missing in this tutorial, please leave a comment down below.
Note that comments are held for moderation to prevent spam.
How to use HC-SR501 PIR Motion Sensor with Arduino
We will understand for what purpose PIR sensor is used? Its basic trigger operations, pin connection details, technical specifications and finally we will be looking at some real life applications. We will begin by understanding the actual PIR sensor unit which are installed inside standard PIR modules and learn its internal characteristics, pinout details and internal working details. What is a PIR Sensor?
Product Tag - BISS0001
Voltage Regulator 3V DC voltage regulator 7. Protection Diode To protect the module from high current. Fresnel lense :The lens is just a piece of plastic. It has three sections A, B and C.