const int pin_to =11;
int prev=LOW;
int curr=LOW;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pin_to,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
prev=curr;
curr=digitalRead(pin_to);
if(prev==LOW && curr==HIGH)
{
Serial.println("motion detected");
}
if(prev==HIGH && curr==LOW)
{
Serial.println("motion stopped");
}
}