Infrared Motion Detector

Sensor

This week in the Construction of a prototype course we studied different sensors and how they work. My partner and I got an infrared motion detector sensor. The motion detector uses infrared lights to detect movement, when it detects something moving it would return a HIGH value. We used a led with the sensor to indicate when the sensor gave that value.

The sensor had three connectors: GND, V+ and Output. We connected the GND to ground, V+ to a pin which supplied +5v and the output connector to pin 12. After the sensor was ready, we added a led to pin 8, so we could see if the sensor picked up anything.

After the connections were ok we moved on to the code. First we created three variables: int sensor, int ledPin and int movement. The movement variables purpose is to store the values that the sensor gives. After that we moved on to setup. We set the led as OUTPUT and the sensor as INPUT.  Then it was time for the last part of the code, creating the loop. The movement variable was set to read the data that the sensor on pin 12 provided and then movement was set as value to digitalwrite with the ledPin variable. Now we could read the sensor and forward the information to the led.

Now it was time to test if everything worked. After the code was inserted to arduino we had to calibrate the sensor. We did this by covering the sensor for 60 seconds so it wouldn’t sense any movement. After the calibration was completed we removed the cover and the sensor started working. Everytime it sensed movement the led would blink. The blinkin changed whether the sensors jumper was set on Normal mode or Retrigger mode. Normal mode give continuously HIGH and LOW pulse which would make the led blink. The Retrigger mode would remain as HIGH value when sensing movement, which means the led would be on the time when sensor picked up movement. In both settings the output would be low when idle.

The code used in project

int sensor = 12;
int ledPin = 8;
int movement = 0;

void setup()
{
 pinMode(ledPin, OUTPUT);
 pinMode(sensor, INPUT);
}

void loop()
{
  movement = digitalRead(sensor);
  digitalWrite(ledPin, movement);
}


Short video clip showing how the sensor works.

About these ads

Tags: , , ,

2 Responses to “Infrared Motion Detector”

  1. Tachyon says :

    Unscientific and all around incorrigible. The experiment carried out requires proper scientific rigor, that includes understanding of infrared measurement (=electromagnetic radiation) by principle of diffraction. I hope by the next project you will have improved in these aspects.

    Regards,

    Physicist

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: