Connecting the pir sensor sr 501. Overview of the infrared motion sensor HC-SR501

HC-SR501 Space Sensor Overview

The HCSR501 motion (or presence) sensor module based on the pyroelectric effect consists of a 500BP PIR sensor (Fig. 1) with additional electrical isolation on the BISS0001 chip and a Fresnel lens, which is used to increase the viewing radius and amplify the infrared signal (Fig. 2). The module is used to detect the movement of objects emitting infrared radiation. The sensing element of the module is a 500BP PIR sensor. The principle of its operation is based on pyroelectricity. This is the phenomenon of the appearance of an electric field in crystals when their temperature changes.

The sensor operation is controlled by the BISS0001 chip. There are two potentiometers on the board, with the help of the first one the object detection distance is set (from 3 to 7 m), with the help of the second one - the delay after the first operation of the sensor (5 - 300 sec). The module has two modes - L and H. The operating mode is set using a jumper. L mode is a single operation mode, when a moving object is detected, a high signal level is set at the OUT output for the delay time set by the second potentiometer. During this time, the sensor does not respond to moving objects. This mode can be used in security systems to give an alarm signal to the siren. In H mode, the sensor is triggered every time motion is detected. This mode can be used to turn on the lighting. When the module is turned on, it is calibrated, the calibration duration is approximately one minute, after which the module is ready for operation. Install the sensor preferably away from open light sources.

Figure 1. PIR Sensor 500BP

Figure 2. Fresnel lens

Specifications HC-SR501

  • Supply voltage: 4.5-20V
  • Current consumption: 50 mA
  • Output voltage OUT: HIGH - 3.3 V, LOW - 0 V
  • Detection interval: 3-7m
  • Delay duration after firing: 5 - 300 sec
  • Viewing angle up to 120
  • Blocking time until the next measurement: 2.5sec.
  • Operating modes: L - single operation, H - operation on each event
  • Working temperature-20 to +80C
  • Dimensions 32x24x18 mm

Connecting an Infrared Motion Sensor to an Arduino

The module has 3 outputs (Fig. 3):
  • VCC - power supply 5-20 V;
  • GND - ground;
  • OUT - digital output (0-3.3V).

Figure 3. Pin Assignment and HC-SR501 Setup

Let's connect the HC-SR501 module to the Arduino board (Connection diagram in Fig. 4) and write a simple sketch that signals with a sound signal and a message to the serial port when a moving object is detected. To fix the triggers by the microcontroller, we will use external interrupts on input 2. This is an int0 interrupt.

Figure 4. Connection diagram for connecting the HC-SR501 module to the Arduino board

Let's upload the sketch from Listing 1 to the Arduino board and see how the sensor reacts to obstacles (see Figure 5). Set the module to work mode L. Listing 1 // Sketch for an overview of the motion/presence sensor HC-SR501 // site // contact for connecting the sensor output #define PIN_HCSR501 2 // trigger flag boolean flagHCSR501=false; // speaker connection pin int soundPin=9; // sound signal frequency int freq=587; void setup() ( // initialize serial port Serial.begin(9600); // start interrupt handling int0 attachInterrupt(0, intHCSR501,RISING); ) void loop() ( if (flagHCSR501 == true) ( ​​// Message to serial port Serial.println("Attention!!!"); // sound signal for 5 sec tone(soundPin,freq,5000); // reset flag flagHCSR501 = false; ) ) // handle interrupt void intHCSR501() ( // setting the sensor trigger flag flagHCSR501 = true; )

Figure 5 Serial Monitor Output

Using potentiometers, we experiment with the duration of the signal at the OUT output and the sensitivity of the sensor (the distance of fixing the object).

Usage example

Let's create an example of sending sms when a motion/presence sensor is triggered on a protected object. To do this, we will use a GPS / GPRS shield. We will need the following details:
  • arduino uno board
  • GSM/GPRS shield
  • npn transistor, for example C945
  • resistor 470 ohm
  • speaker 8 ohm 1W
  • wires
Let's assemble the connection diagram according to fig. 6.

Figure 6. Connection diagram

When the sensor is triggered, we call the procedure for sending sms with a text message Attenaction!!! to the PHONE number. The contents of the sketch are shown in Listing 2. The GSM/GPRS shield consumes up to 2 A in sms sending mode, so we use an external 12V 2A power supply. Listing 2 // Sketch 2 for an overview of the motion/presence sensor HC-SR501 // sending sms when the sensor is triggered // site // contact for connecting the sensor output #define PIN_HCSR501 2 // trigger flag boolean flagHCSR501 false; // speaker connection pin int soundPin=9; // sound signal frequency int freq=587; // SoftwareSerial library #include // phone number to send sms #define PHONE "+79034461752" // Pins for SoftwareSerial (you may have 2,3) SoftwareSerial GPRS(7, 8); void setup() ( // initialization of the serial port Serial.begin(9600); // start of interrupt processing int0 attachInterrupt(0, intHCSR501,RISING); // to communicate with the GPG/GPRS shield GPRS.begin(19200); ) void loop() ( if (flagHCSR501 == true) ( ​​// Message to the serial port Serial. println("Attention!!!"); // sound alarm for 5 seconds tone(soundPin, freq, 5000); // send sms SendSMS(); // reset the trigger flag flagHCSR501 = false; ) ) // interrupt processing void intHCSR501() ( // setting the sensor trigger flag flagHCSR501 = true; ) // subroutine for sending sms void SendSMS() ( // AT command text mode settings GPRS.print("AT+CMGF=1\r"); delay(100); // phone number GPRS.print("AT + CMGS = \""); GPRS.print(PHONE); GPRS. println("\""); delay(200); // GPRS message. println("Attention!!!"); delay(200); // ASCII code ctrl+z – end of GPRS transmission. println((char) 26); delay(200); GPRS.println(); )

Frequently Asked Questions FAQ

1. The module does not work when the object moves
  • Check if the module is connected correctly.
  • Set the sensing distance with the potentiometer.
2. The sensor is triggered too often
  • Adjust the signal duration delay with the potentiometer.
  • Set the jumper to single operation mode L.

In the face of ever-increasing electricity tariffs, it's time to think about saving it. And when it comes to lighting, this can be achieved by using LED light sources, which save energy to a large extent. Also, in addition to them, motion and light sensors are installed, which allow you to automate the lighting process and thereby increase the life of the LED light source, which has a rather high price, and also reduces power consumption. These LED light sources respond to both room illumination and movement, while working in conditions when it is needed. Turning off such LED light sources occurs independently after a while. LED lamp with motion sensor has proven itself to work both indoors and outdoors. It is worth noting that the installation of LED lamps with a motion sensor is possible even in hard-to-reach places where there is no way to supply electricity. The advantage of such LED lamps with a motion sensor is that it will not consume electricity unnecessarily and thus save it. At the same time, there is no need to install a switch under it, which then will have to be looked for in the dark. Moreover, if a photo sensor is installed in the device, then this LED lamp will respond not only to movement, but also to the level of illumination. If the lamp is installed on the street, then at dusk it will turn on automatically, and turn off when there is sufficient lighting.

Well, let's start in order and make such an LED lamp ourselves. For this we need the following:

  • carcass
  • mounting wires
  • foil fiberglass
  • 12v power supply or battery.

Sensor HC-SR501

To set modes on the sensor HC-SR501 there are two potentiometers (time and sensitivity) and a jumper (see picture below):

Key Features of HC-SR501:

  • Working voltage: DC 4.5V - 20V
  • Output signal: high / low level(0 or 1), signal: 3.3V TTL level
  • Detection range: 3 - 7 Meters (adjustable by "sensitivity" potentiometer)
  • Detection angle: 120-140° (Depends on installed Fresnel lens)
  • Trip delay time: 5-300 seconds (adjustable by "time" potentiometer, default 5s -3%)
  • Operating Temperature: -20 - 80°C
  • Working mode:
    - Mode H - in this mode, when the sensor is triggered several times in a row, its output (at OUT) remains at a high logic level.
    - Mode L - in this mode, a separate pulse appears at the output each time the sensor is triggered.

After selecting the sensor operation mode, adjusting the sensitivity and response time, let's move on to one more important point installation of a photoresistor, since in addition to standard sense organs, a pyroelectric sensor has the ability to install a photoresistor. Often there are free contacts on the connection board. In the diagram below, its contacts are designated as RL.

When a photoresistor is connected, the device will only work in the dark. Since if you illuminate the photoresistor, its resistance will decrease and the voltage on leg 9 of the DA1 microcircuit will be insufficient to turn on. You can adjust the turn-on threshold by connecting a tuning resistor in parallel with resistor R9. It must be connected through a resistance of 1 ... 4.7 kOhm in order to prevent a short circuit at low resistances of the photoresistor. The photoresistor is installed on the sensor board in the place circled in yellow (see the pictures below).


12v led strip

More recently, a number LED lamps replenished with lamps, which are thin flexible ribbons up to 5 meters long with the possibility of increasing their length. The tape can also be cut into small pieces, a few centimeters long. When choosing led strip the main lighting characteristic is the intensity of the luminous flux, which is expressed in lumens per meter (lm / m). The amount of luminous flux is determined by the type and number of LEDs installed on one meter of tape. Knowing the type of LEDs and their number, it is easy to independently determine the luminous flux.

For example, a meter of white light LED strip has 30 type 3528 LEDs with a luminous flux of 5 lumens per LED. We multiply 5 lm by 30 LEDs, we get 150 lm. Approximately such a luminous flux emits a 10-watt incandescent light bulb.

Flexible LED strip device plastic tape up to 5 m long there are thin copper conductive tracks of the required configuration. LEDs and current-limiting ones are soldered to the tracks. With a supply voltage of 12V, three LEDs connected in series and one or more current-limiting resistors are installed. The number of resistors is determined depending on the amount of power dissipated on them (see the figure below).

To mount the LED strip, a sticky layer protected by a film is applied on one side. In order to fix the tape on the surface, it is necessary to remove protective film and attach the sticky side to the installation site. If necessary, the LED strip can be cut. The cutting step is determined by the number of LEDs connected in series and is separated on both sides by pads that allow you to solder wires to them (see the figure above). For the LED lamp, 4 pieces of LED strip with 5630 LEDs were used.

frame

Since LEDs are afraid of overheating, good heat dissipation is necessary for their long service life. In this regard, the frame was made of an aluminum plate 2 mm thick. Holes for fasteners and wire laying are also drilled in the frame (see pictures below).

Mounting wire

Mounting wires are used for the installation of radio components and radio components, assemblies and blocks of radio-electronic equipment, the installation of electrical apparatus and devices. Conductive cores of mounting wires are tinned copper wires that allow connections by soldering with low-temperature solders. Stranded flexible wires provide installation flexibility and reliable protection against external influences. The insulation material is glass and nylon threads, triacetate film tapes used in the temperature range of -60 ... +105 ° C, polyvinyl chloride and polyethylene insulation with an additional protective sheath made of nylon, resistant to moisture, oils and fungal mold.

Foil fiberglass

Foiled glass-textile sheet material is made from fiberglass, which is impregnated epoxy resin. A layer of galvanic copper foil with a thickness of 35 µm or 50 µm is applied to the surface of the product. So we will make contact pads and a printed circuit board of a transistor key from it.

12V power supply or battery

The power supply converts the AC voltage of the home electrical network voltage 220V to the specified constant voltage.

It's time to consider the scheme of this lamp.

Photo of the assembled version of the LED lamp

List of radio elements

Designation A type Denomination Quantity NoteScoreMy notepad
P1 SensorHC-SR5011

In the struggle for the life of incandescent lamps on the landing, I tried a fairly large number of schemes for their protection. These were both simple diodes and soft start circuits, and acoustic sensors. Not all have proven themselves on the positive side. Going to the Aliexpress website, I came across a pyroelectric sensor HC-SR501. At a price of less than one dollar, the sensor has a number of positive qualities, namely: power supply from 5 to 20 volts, motion detection zone from 3 to 7 meters, turn-off delay from 5 to 300 seconds. ( Full description I don’t see the point here, since this information is more than enough). Externally, the sensor looks like this:

Just what you need to illuminate the landing, where people do not walk so often and the constant glow of the lamp is useless.

The photo below shows the connection points for the common wire (GND), the trigger signal output (Output) and the power bus (+ Power). The board has two variable resistances: one regulates the response zone (Sensitivity Adjust), the other the turn-off delay (Time Delay Adjust).

In addition, there is a jumper for switching modes. H and L. In mode L the sensor, having fixed the movement, outputs a high-level signal. Regardless of whether there is further movement in the detection area or not, after a set delay time (for example, 30 seconds), the output signal will be turned off.

In mode H the output signal will disappear only after the delay time has elapsed from the moment of the last motion detection in the detection zone. That is, they passed through the movement zone - it will turn off after 30 seconds, stay and move in the detection zone for 10 minutes and leave it - it will turn off after 30 seconds. While you are in the detection zone, the sensor will not turn off.

Just what you need to illuminate the landing, where people do not walk so often and the constant glow of the lamp is useless. Having studied the datasheet and materials on the network, I discarded the Arduino use cases as excessively costly and sketched the following circuit.

Functionally, the device consists of three nodes:

  1. the HC-SR501 sensor itself;
  2. an actuator consisting of a resistor R3, a transistor VT1, a diode D1 and a relay P1, where R3 and VT1 serve as a link between the sensor and the relay. Without them, the load capacity of the sensor is so low that only an LED can be connected directly;
  3. transformerless power supply, where R1 is necessary to reduce the inrush current (often it can be neglected), capacitor C1 with a rating of 0.47 - 0.68 uF with an operating voltage of at least 250 volts provides an output current of up to 0.05 A, R2 is necessary for discharging capacitor C1 after disconnecting the device from the network.

Why a diode bridge is known to everyone. The filter capacitor should be selected with an operating voltage of at least 25 volts. Well, finally, the zener diode sets the voltage at the output of the power supply at 12 volts. The choice of a zener diode specifically for 12 volts is due, on the one hand, to the supply range of the sensor from 3 to 20 volts, on the other hand, the operating voltage of the relay is 12 volts.

Separately, it is worth mentioning the transistor. This is practically any NPN transistor structure - 2N3094, BC547, KT3102, KT815, KT817, etc. etc.

A relay with almost any coil resistance, a switching voltage of 250 volts and a current of 3 amperes, which will make it possible to safely switch a load of several hundred watts.

You can buy the sensor in the FastAVR project partner store with a 10% discount if you follow the link

Motion Sensor ( PIR Motion sensor) HC-SR501 connection to Arduino

PIR-sensor is translated from English as Pyroelectric (Passive) InfraRed sensor - a pyroelectric (passive) infrared sensor. Pyroelectricity is the property of generating a certain electric field when a material is irradiated with infrared (thermal) rays. Therefore, PIR sensors make it possible to detect the movement of people in a controlled area, since the human body radiates heat. Such sensors are small in size, inexpensive, and have low power consumption. They are easy to use and do not wear out. For these reasons, they are used in most industrial motion sensors.
Do not place PIR sensors in places where the temperature changes rapidly. This will lead to the fact that the sensor will not be able to detect the appearance of a person in the controlled area, and there will be many false positives.
Thanks to our "Chinese brothers", a module consisting of the PIR sensor itself and the control circuit has become very popular for home use. They combined everything into one module and called it HC-SR501.

Basic parameters of the HC-SR501 module

Parameter Value
Dimensions approx 3.2cm x 2.4cm x 1.8cm
Supply voltage DC 4.5V- 20V
Current on OUT o -140 o (depending on the specific sensor and lens)

Pulse duration
on detection 5 - 200sec.(configurable)

Blocking time up to
next measurement 2.5sec. (but can be changed by replacing SMD resistors)

Working temperature -20 - +80 o C
Operating mode L - single capture, H - repeated measurements

Description
The whole module looks like this:

And this is what it looks like with the Fresnel lens removed. What is this lens can be read on Wikipedia. The photo shows the PIR sensor 500BP.

Closer up

And this back side module with a power supply and control circuit.

The module has several settings. Two switches and a jumper. From the picture, I think everything should be clear.

Operating modes

The module operation mode is set by a jumper. There are two modes - H mode and L mode. In the photo above, the module is set to H mode.

  • H mode- in this mode, when the sensor is triggered several times in a row, its output (at OUT) remains at a high logic level.
  • L mode- in this mode, a separate pulse appears at the output each time the sensor is triggered.

Well, one more picture, copied from the datasheet to the PIR sensor:

Scheme

You can check the operation of the sensor by assembling on a breadboard the simplest scheme. As an indicator, a conventional LED is used here.

Assemble this diagram. The jumper must be set to operating mode L. Apply power. Wait approximately 20-40 seconds (up to 60 seconds for some modules). At this time, the sensor is being calibrated.
Now, as soon as the sensor detects movement, the LED will glow for a certain time, set by the tuning resistor. You can play around with setting the sensitivity and installing the module in different places in the house.
It is better (although not necessary) to connect the module to microcontrollers (well, or other microcircuits) through a transistor and a 10k pull-up resistor. Here is an example diagram:

Or here:

In this article I will tell you how to work with the HC-SR501 sensor (PIR sensor). The sensor is inexpensive and versatile, it can be used either alone or with a microcomputer to create various projects (systems burglar alarm or automated systems lighting)

Specifications

Supply voltage: 4.8V ... 20V
Static current: 50mA
Output level: 3.3V / low 0V
Delay time: 0.5 - 200s (adjustable)
Blocking time: 2.5s
Work Angle:< 100
Working temperature: -15C … + 70C
Object detection: 23mm
Dimensions: 33mm x 25mm x 24mm

General information

Any person or animal with a temperature above zero emits heat energy in the form of radiation. This radiation is not visible to the human eye because it is emitted at infrared wavelengths, below the spectrum that humans can see. Measuring this energy is not the same as measuring temperature. Since the temperature depends on the thermal conductivity, therefore, when a person enters the room, he cannot instantly change the temperature in the room. However, there is a unique infrared emission due to body temperature that the PIR sensor is looking for.
The principle of operation of the infrared motion sensor HC-SR501 is simple, when turned on, the sensor adjusts to "Normal" infrared radiation within its detection zone. It then looks for changes, such as a person walking or moving within a controlled area. The detector uses a pyroelectric sensor to determine the infrared cure. This is a device that generates an electrical current in response to receiving infrared radiation. Because the transducer does not emit a signal (such as the previously mentioned ultrasonic transducer), it is penalized "passive". When a change is detected, the HC-SR501 changes the output signal.

To improve the sensitivity and efficiency of the HC-SR501 sensor, the method of focusing infrared radiation on the device is achieved, this is achieved by using the "Fresnel Lens". The lens is made of plastic and is made in the form of a dome and actually consists of several small Fresnel lenses. Although plastic is translucent to humans, it is actually completely transparent to infrared light, so it also serves as a filter.

The HC-SR501 is a low cost PIR sensor that is completely self-contained, capable of operating on its own or in conjunction with a microcontroller. The sensor has a sensitivity adjustment that detects movement from 3 to 7 meters and its output can be set to remain high for 3 seconds to 5 minutes. Also, the sensor has a built-in voltage regulator, so it can be powered by a constant voltage of 4.5 to 20 volts and consumes a small amount of current. HC-SR501 has a 3-pin connector, the purpose is as follows:

Pin assignment
VCC— positive DC voltage from 4.5 to 20 V DC.
OUTPUT- 3.3 volt logic output. LOW does not indicate discovery, HIGH means someone has been discovered.
GND- grounding.

The board also has two potentiometers for setting several parameters:
SENSITIVITY— sets the maximum and minimum distance (from 3 meters to 7 meters).
TIME- the time during which the output will remain HIGH after detection. At least 3 seconds, maximum 300 seconds or 5 minutes.

Jumper assignment:
H is the Hold or Repeat setting. In this position, the HC-SR501 will continue to output a HIGH signal as long as it continues to detect motion.
L— This is an interrupt or no retry option. In this position, the output will remain HIGH for the period set by the TIME potentiometer setting.

The HC-SR501 board has additional holes for two components, there is a marking nearby, you can look at it by removing the Fresnel lens.

Purpose of additional holes:
RT- This is for a thermistor or temperature sensitive resistor. Adding this allows the HC-SR501 to be used in extreme temperatures and also improves the accuracy of the detector to some extent.
RL is a connection for a light-dependent resistor or photoresistor. By adding a component, the HC-SR501 will only work in the dark, which is a common application for motion-sensitive lighting systems.

Example #1: HC-SR501 as a standalone device.

Required details:


Transistor 2SC1213 x 1


Connection:
When you turn on the HC-SR501, calibration is required, it takes from 30 to 60 seconds, the sensor also has a “reboot” period of about 6 seconds (after triggering), during which time it does not respond to movements. In this example, we use HC-SR501 and a relay module (1-channel), as well as an NPN transistor (2SC1213 is used in the example). The HC-SR501 sensor is powered from 5 V, since the relay also requires the same power, and a 220V lamp is used as a load. Since the output signal of the HC-SR501 is weak (in practice, it is only enough to light the LED), one option is to use any NPN bipolar transistor.

Attention! Follow safety precautions and be careful!

The operation of this circuit is very simple, after switching on and calibrating, the sensor starts reading. When motion is detected, the sensor changes the value at the “OUT” pin.

Example #2: HC-SR501 adding photoresistor

Required details:
Motion sensor HC-SR501 x 1 pc.
Relay module (1-channel) x 1 pc.
Transistor 2SC1213 x 1
Lamp for 220V (75W) with socket x 1 pc.
Power supply for 5V x 1 pc.
Photoresistor x 1pc
DuPont wire, 2.54 mm, 20 cm, F-M (Female - Male) x 1 pc.

Connection:
In the following example, we use the same circuit as in example No. 1, only a photoresistor has been added. The place for installing the photoresistor is located next to the output connector, the designation on the board is "RL". You can solder directly to the board or use the pin header to easily connect the Dupont wire. The main thing is that the photoresistor should not be closed from the natural light of the room, but also be protected from the light of the lamp, which we use as a load. The figure below shows where to install the photoresistor.

Once the photoresistor is installed, turn on the circuit and wait for a while while the HC-SR501 sensor calibrates. If everything is connected correctly (and the room lights are on), nothing will happen, the photoresistor prevents the HC-SR501 from starting when the room is lit. Now turn off the light and the HC-SR501 will start up whenever it detects activity.

Example #3: HC-SR501 and Arduino

Required details:
Arduino UNO R3 x 1pc
Motion sensor HC-SR501 x 1 pc.
LEDs 5 mm x 3 pcs.
Resistor 0.125W, 320Om x 3 pcs.
DuPont wire, 2.54 mm, 20 cm, F-M (Female - Male) x 1 pc.

Connection:
Although the HC-SR501 sensor and independent device, it can be connected to the output of the microcontroller. In the example, we use the Arduino UNO R3 controller, in which we can take into account the turn-on time and the reset period. This way the device can be more accurate as you won't be trying to sense forward motion when the sensor is not ready. Also, you can connect several HC-SR501 sensors to the Arduino, which will allow you to track movement in different places.
In the following example, we will connect one HC-SR501 to the Arduino as an indication using three LEDs, each of which indicates the status of the sensor:

  • Red LED- This LED indicates that the sensor is not ready.
  • Yellow LED- This LED indicates that the sensor is ready to detect motion.
  • Green LED- This LED lights up for 3 seconds when the sensor is triggered. Instead of an LED, you can control an external output (like the relay module we used earlier).

Wiring diagram:

The jumper on the HC-SR501 must be set to the “L” position, and it is also necessary to set the time to a minimum (5 seconds), to do this, turn the potentiometer to the left until it stops. Now that you're all connected, you need to upload the sketch.

/* Tested on Arduino IDE 1.8.0 Test date 08/12/2016. */int detectedLED = 13; // Specify the pin int readyLED = 12; // Specify the pin int waitLED = 11; // Specify the pin int pirPin = 7; // Specify the pin of the sensor int motionDetected = 0; // Variable for motion detection int pirValue; // Variable to store value from PIR void setup() ( pinMode(detectedLED, OUTPUT); // Set pin as output pinMode(readyLED, OUTPUT); // Set pin as output pinMode(waitLED, OUTPUT); // Set pin as output pinMode(pirPin, INPUT); // Set pin as input // Initial delay of 1 minute to stabilize the sensor// digitalWrite(detectedLED, LOW); digitalWrite(readyLED, LOW); digitalWrite(waitLED, HIGH); delay( 60000); digitalWrite(readyLED, HIGH); digitalWrite(waitLED, LOW); ) void loop() ( pirValue = digitalRead(pirPin); // Read the value from the motion sensor if (pirValue == 1) // If there is movement, make a delay of 3s ( digitalWrite(detectedLED, HIGH); motionDetected = 1; delay(3000); ) else ( digitalWrite(detectedLED, LOW); ) // Delay after triggering // if (motionDetected == 1) ( digitalWrite (detectedLED, LOW); digitalWrite(readyLED, LOW); digitalWrite(waitLED, HIGH); delay(6000); digitalWrite(readyLED, HIGH); digitalWrite(wai tLED, LOW); motionDetected = 0; ) )

Tested on Arduino IDE 1.8.0

Date of testing 12.08.2016

int detectedLED = 13 ; // Specify the pin

int readyLED = 12 ; // Specify the pin

int waitLED = 11 ; // Specify the pin

int pirPin = 7 ; // Specify the pin of the sensor

int motionDetected = 0 ; // Variable for motion detection

int pirValue ; // Variable to save value from PIR

void setup()

pinMode (detectedLED , OUTPUT ) ; // Set pin as output

pinMode (readyLED , OUTPUT ) ; // Set pin as output

pinMode (waitLED , OUTPUT ) ; // Set pin as output

pinMode (pirPin , INPUT ) ; // Set pin as input

// Initial delay 1 minute, to stabilize the sensor //

digitalWrite (readyLED , LOW ) ;

digitalWrite (waitLED , HIGH ) ;

delay(60000) ;

digitalWrite (readyLED , HIGH ) ;

digitalWrite (waitLED , LOW ) ;

void loop()

pirValue = digitalRead(pirPin) ; // Read the value from the motion sensor

if (pirValue == 1 ) // If there is movement, we make a delay of 3 seconds.

digitalWrite(detectedLED , HIGH ) ;

motionDetected = 1 ;

delay(3000) ;

else

digitalWrite (detectedLED , LOW ) ;