motion sensor interfacing with MSP430G2 LaunchPad

In this tutorial, you will learn how to interface motion sensor with MSP430G2 LaunchPad . There are many types of motion sensors available in market, But in this tutorial, we be using PIR motion sensor. We will see how to detect motion of any object around this PIR motion sensor and how to interface it with MSP430G2 LaunchPad  to detect motion. This tutorial can also be used as a motion detector project. This is a fourth tutorial on series of tutorials on MSP430G2 LaunchPad.  To understand this guide completely, you should know about general purpose input/ output pins of MSP430G2 LaunchPad . You should also know how to use energia IDE to program MSP430G2 LaunchPad . If you have no knowledge about how to use MSP430G2 LaunchPad and how to program it using Energia IDE, you should read following two articles first:

Now lets start with a introduction of motion detector sensor or motion sensor. I have already mentioned about the sensor which we are using in this tutorial. In this tutorial,  we will use PIR sensor to sense the motion (movement) of human being and turns ON an LED to indicate about the detection of motion. Movement of human will be detected by the PIR sensor. PIR Sensor provides a triggering pulse to MS430G2 launchPad  . MS430G2 launch Pad generates output at Pin No. 14 to turn ON the LED.

Introduction to motion sensor MOTION SENSOR

PIR motion sensors are basically  passive infrared receivers what you would more commonly call a motion sensor.  So what it actually has in it is a underneath  plastic dome is a very sensitive infrared sensor that receives and measures the general temperature of the room around it. When you move it senses the change in the average temperature to enough precision that it can actually identify when you’re moving around. These modules are pretty impressive because it only have three pins
  • five volts
  • ground
  • in the middle it has a pulse output so that every time it sees motion it pulses out 3.3 voltsmotion sensor working
This module happens to have two adjustment potentiometers on it. So you can turn up or down the sensitivity and the pulse duration. Because obviously when it senses motion it’s going to send out a pulse but then it after the pulse it does a hold off. It will then not send another pulse until it waits a certain amount of time. These things are really kind of impressive setting. I can be 20 feet away from it and move over 6 inches and it’ll detect it.

Motion sensor interfacing with MSP430G2 LaunchPad

In this circuit we are using pin number 13 as digital input pin which is connected with output pin of PIR sensor. Because PIR sensor gives logic high whenever it detects motion around and there is no motion around it will give logic low output. Terminal of PIR sensor is connected with ground and terminal three is connected with 5 volt TPI pin. I told you earlier about TPI pin.  PIR sensor works on 5 volt so if you connect less than 5 volt to power supply pin of PIR sensor, it will not work properly.  LED is used for indication. LED is connected with pin number 14 which will be initialized as a digital output pin in program.


Code of MSP430G2 LaunchPad interfacing with motion sensor

Code for PIR sensor is same as code for Push button interfacing with MS430G2 LaunchPad

int ledpin = 14;
int motion_sensor = 13;
int sensor_state;

void setup()
pinMode(ledpin, OUTPUT);
pinMode(motion_sensor, INPUT);

void loop()
sensor_state = digitalRead(motion_sensor);
if (sensor_state == HIGH)
digitalWrite(ledpin, HIGH);
digitalWrite(ledpin, LOW);

Leave a Comment