PIR Motion Sensor

From Digipool-Wiki
Revision as of 17:57, 18 June 2013 by WikiSysop (Talk | contribs) (Created page with " <br> Code <source lang = "java"> // PIR Motion Sensor // SEN-08630 by sparkfun // // red wire = +5V // brown or the white wire = GND // black wire = pirPin (2) int pirPin ...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Code <source lang = "java">

// PIR Motion Sensor // SEN-08630 by sparkfun // // red wire = +5V // brown or the white wire = GND // black wire = pirPin (2)


int pirPin = 2; //digital 2

void setup(){

 Serial.begin(9600); 
 Serial.println(" ");
 Serial.print("Calibration");
 pinMode(pirPin, INPUT);
 digitalWrite(pirPin, HIGH);
 delay(3000);
 Serial.println(" completed");

}


void loop(){ int pirVal = digitalRead(pirPin); //int pirVal = analogRead(5);

 //Serial.println(pirVal);
 //delay(500);


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

} </source>