1407 views|0 replies

1140

Posts

0

Resources
The OP
 

Motion Detector Using MSP430 Launchpad and PIR Sensor [Copy link]

Motion detection is an important part of security system and PIR sensor is one of the most commonly used sensors to trigger alarm when motion is detected. This sensor can easily detect the motion of people/animals by sensing the infrared rays emitted by them. Today, we will make the same type of motion detection alarm by interfacing PIR sensor with TI-MSP430.


Required Materials

● PIR sensor module

● TI-MSP430 Launchpad development board

● LED

● Buzzer

● Breadboard

● Jumper


PIR Sensor Module

PIR Sensor (Passive Infrared Sensor) stands for Passive Infrared Sensor and can detect multiple levels of radiation. As we all know, every object emits some radiation and hotter materials emit more radiation than other substances. That is why this sensor can detect the presence of people/animals as they are hotter than other materials around them. This module consists of a pyroelectric sensor that detects the presence of human/animal body. And there is a Fresnel lens attached to the sensor that increases the range of the sensor. The pinout of the PIR Sensor Module is as follows:

The module is adjustable, i.e. the sensitivity and time trigger can be adjusted by rotating the knobs of two potentiometers on the board.


There are two operating modes: retrigger (H) mode and non-retrigger (I) mode.

In retrigger or H mode, the output remains high as long as motion occurs. In non-retrigger or I mode, the output remains high and then goes low after the trigger time, and this process continues as long as the motion continues. Most applications use H mode, and we will use this mode only as well. The PIR sensor works well with a 5V to 12V power supply. But it can also be powered by the 3.3V pin of the MSP430.


Interfacing PIR Sensor Module with TI-MSP430

Interfacing the PIR sensor with MSP430 is very simple. The VCC and GND pins of the module are connected to the VCC and GND pins of the MSP430. The output pin of the module is connected to the 8th pin (P2.0) of the MSP430. Although any pin can be used, you have to declare the mode of the pin as input. The 6th pin (P1.4) is connected to the LED and buzzer.


PIR sensor module programming for TI-MSP430

The code is very simple and the complete code is given at the end of this article. Here, we will make the LED blink and make a continuous beep sound when the PIR sensor detects any motion.

In the setup function, we declare that pin 8 will be used as an input pin since it takes the output from the PIR module and pin 6 will be used as an output pin since it is connected to the LED and buzzer.

void setup()
{
pinMode(8, INPUT);
pinMode(6, OUTPUT);
}

Next in the loop function, first we check if the output of the PIR module is high or not. Now, if the output of the PIR module is high, it means some movement is detected. So, to indicate this, we take pin 6 low and high with a time delay of 100 milliseconds so that continuous flashing and buzzing sound can be experienced.

void loop()
{
If(digitalRead(8) == HIGH)
{
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
}
}
复制代码

Finally upload the code to the MSP430 using Energia IDE, power the board and wait for about a minute. The PIR sensor module needs some time to calibrate. After a minute, move your hand in front of the sensor and it should work. After you remove your hand, the flashing and buzzing will stop. You can also try changing the sensitivity and time trigger using the two potentiometers on the PIR sensor.

The complete code used in this article is as follows:
Code main.rar (219 Bytes, downloads: 2)

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list