int sensor = 2;
int val; // the pin that the sensor is atteched to
void setup() {
pinMode(sensor, INPUT); // initialize sensor as an input
Serial.begin(9600); // initialize serial
}
void loop(){
val = digitalRead(sensor); // read sensor value
if(val>0){
Serial.println("Motion detected!");
}
else{
Serial.println("Motion not detected!");
}
delay(1000);
}