# Is this how motion sensors work?

**URL:** https://discourse.processing.org/t/is-this-how-motion-sensors-work/31792
**Category:** Libraries
**Created:** [August 19, 2021, 4:34pm UTC](https://discourse.processing.org/t/is-this-how-motion-sensors-work/31792 "2021-08-19T16:34:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MoonAlien822](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)
#### Post date: [August 19, 2021, 4:34pm UTC](https://discourse.processing.org/t/is-this-how-motion-sensors-work/31792/1 "2021-08-19T16:34:16Z")

</div>

```auto
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");}
}

```

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [August 19, 2021, 8:16pm UTC](https://discourse.processing.org/t/is-this-how-motion-sensors-work/31792/2 "2021-08-19T20:16:53Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![MoonAlien822](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)
#### Post date: [August 19, 2021, 8:26pm UTC](https://discourse.processing.org/t/is-this-how-motion-sensors-work/31792/3 "2021-08-19T20:26:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [August 19, 2021, 8:31pm UTC](https://discourse.processing.org/t/is-this-how-motion-sensors-work/31792/4 "2021-08-19T20:31:44Z")

</div>

1. read [guidelines](https://discourse.processing.org/t/guidelines-asking-questions/2147) 🙂
