Is this how motion sensors work?

color[] firstframe;
color[] secondframe;
int i= 1;
int x;
int y;
void draw(){
  firstframe[i]=get(x,y);
  
  delay(500);
  
  secondframe[i]=get(x,y);
  
  if (firstframe[i]==secondframe[i]){
    i++;
    y++;
    if(y==1920){x++; y=1;}
    }
if(firstframe[i]!=secondframe[i]{
print("motion detected");}
}

Hi! It would be great if you can add text to describe what you want to do. What do you mean by motion sensor? Is it a camera? Which platform are you using?

  1. you would have to add video feed to the program and then it looks for changes in the image, often motion. hense motion sensor
  2. this is processing.org
  1. read guidelines :slight_smile: