counting with IR sharp sensor

Hello, i am new in this domain, but i want same help with a project from my work.

i have an arduino mega, 5 servo(external powered: Pololu - Power HD Standard Servo 6001HB, and 5 IR sharp sensor: http://www.pololu.com/product/1134, and 1 relay: Pololu Basic 2-Channel SPDT Relay Carrier with 5VDC Relays (Assembled)

the project is like this:

i want the sensor to count object passes in front of them, independly, in any direction. I mean when an object passes in front of sensor, lets say sensor 1, arduino to count 1, on three passes, count 3 an move servo1 in an distinct pozision, let say 90degree. when sensor 2 count 3 passes, move servo 2, in an distinct pozision, and so on with all of 5 sensors and five servos. when all sensor count eachone 3 passes, so the total are 15, i need to activate an relay.

i need help with the code and with the sche.
matic. In this moment i can do servo to move, but i dont know how to do counting the ir sensor and conected with servos.

forget my bad english, if is something you dont undferstand, pls tell me, and i do my best to explain.

can i get same help from you on this project? if you cant help me i dont know where to ask...

what do you thing about this?

#include <Servo.h>

Servo myservo1;

int sensorPin1 = 3;

int val1 = 0;

int counter1 = 0;

int currentState1 = 0;

int previousState1 = 0;

void setup()
{
myservo1.attach(52);

pinMode(sensorPin1, INPUT); // declare pushbutton as input

Serial.begin(9600);
}

void loop()

{

if (counter1<3)
{
{
val1 = digitalRead(sensorPin1);
if (val1 == LOW)
{
currentState1 = 1;
}
else
{
currentState1 = 0;
}
if(currentState1 != previousState1)
{
if (currentState1 == 1 && previousState1 == 0)
{
counter1 = counter1 + 1;
Serial.println(counter1 + counter2 + counter3+100);
delay(timp_asteptare_citire);
}
}
}
}
else
{
myservo1.write(180); // tell servo to go to position in variable 'pos'
}
previousState1 = currentState1;