Pages: [1]   Go Down
Author Topic: Stupid PIR Sensor  (Read 390 times)
0 Members and 1 Guest are viewing this topic.
Vermont
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I have been trying for a while to get a RIP motion sensor to work. This is the sensor https://www.sparkfun.com/products/8630 I have wired it exactly as in this picture. http://bildr.org/blog/wp-content/uploads/2011/06/PIR-Arduino_hookup.png Here is my code:
Code:
int pirPin = 2; //digital 2

void setup(){
 Serial.begin(9600);
 pinMode(pirPin, INPUT);
}

void loop(){
  int pirVal = digitalRead(pirPin);

  if(pirVal == LOW){ //was motion detected
    Serial.println("Motion Detected");
    delay(150);
  }

}

Can someone please help me? Thanks!!
Logged

I enjoy electrical engineering and robotics engineering. I have a Arduino Mega 2560 based rover with ultrasonic, infrared and gyroscopic cap

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46026
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can someone please help me?
Sure. What is the problem?

Sparkfun says that it is a 12V sensor. You are powering it from 5V.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 63
Posts: 6049
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the problem? 

Have you verified the value of the resistor you are using?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Vermont
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I do have a 10K ohm resistor, I will try powering it with 12V. It is not returning any data, and it quite frustrating, as it is a remarkably simple device.
Logged

I enjoy electrical engineering and robotics engineering. I have a Arduino Mega 2560 based rover with ultrasonic, infrared and gyroscopic cap

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46026
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It is not returning any data
No data? Or, not the data you want?
Logged

Vermont
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After fiddling some more, I get it saying there is motion even when it is in a dark box. Here is my new code. The data I want is pin 2 to go LOW if there is motion, and HIGH if there is not. Here is my slightly updated code:
Code:
int pirPin = 2; //digital 2

void setup(){
 Serial.begin(9600);
 pinMode(pirPin, INPUT);
}

void loop(){
  int pirVal = digitalRead(pirPin);

  if(pirVal == LOW){ //was motion detected
    Serial.println("Motion Detected");
    delay(150);
  }else{
    Serial.println("No Motion");
  }

}

And I am now using a Ni-MH 12V battery.
Logged

I enjoy electrical engineering and robotics engineering. I have a Arduino Mega 2560 based rover with ultrasonic, infrared and gyroscopic cap

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46026
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And I am now using a Ni-MH 12V battery.
For what? A schematic is essential.
Logged

Pages: [1]   Go Up
Jump to: