Go Down

Topic: People Counter with infrareds (Read 3349 times) previous topic - next topic

carolmattos

Hi,
I'm making a 'people counter' using infrared sensors (wich i already have). If someone passes from infrared A to infrared B, it means they're entering the place. If someone goes from infrared B to infrared A, then it means they're leaving. The counter will be the imput, and the number of people inside will influence on the output (behavior of the leds conected to the board). I need to know wich kind of code i can use in order to relate the counting with the output.
carol

PaulS

This topic has been discussed many times, and it is not a simple as you make it out to be. What happens if two people enter at once? What happens if someone breaks the first beam, and then backs out, never tripping the second beam? What happens if someone breaks both beams, but then backs up and reenters the room.

If you can ensure that none of these conditions can happen, then you can successfully count the number of people in the room.

Quote
I need to know wich kind of code i can use in order to relate the counting with the output.

Only you know what you want the Arduino to do based on the number of people in the room.

carolmattos

The infrareds will be really close to each other, so even if the person backs up and enter the room again, the infrareds will register 'entering-leaving-entering' so it won't be a problem. The counting doesn't need to be too accurate, i just want to know how to program arduino to register it.. I want it to consider 'AB' as +1 and 'BA' as -1, but i don't know how to.

It's actually a project for college, so it doesn't need to be perfect. Arduino is demanded, but i never used it before and i'm having a few problems programming the board (it's my first time using a board, as well). Also, english isn't my first language, wich make things even harder. So i'm sorry if i'm a bother for asking trivial questions in a forum mostly composed by experts, i was just hoping you could help me in some way, since you're so experienced...
carol

Big Oil

here's part of it.  It hasn't been tested.  Read up here also: http://www.arduino.cc/en/Reference/HomePage
Code: [Select]

if (infrared1 > value){
     a=1;
}

if (infrared2 > value){
     b=1;
}

if(a > b){
  entering = 1;
} else if (b > a){
     leaving=1;
}

if ((a + b) ==2){
      if (entering == 1){
     total = total + 1;
     }  else if (leaving == 1){
    total = total - 1;
     }
entering=0; // reset everything
leaving=0;
a=0;
b=0;
}

carolmattos

Wow, thanks! That's gonna help me a lot!!!
carol

Go Up