"The Problem is when i run this code, the count does not increment when the object passes the two sensors"
If this is the case, it may occur every iteration, no possible conditions are met to allowing the counts increment.
if x == 0
pause(2)
if x ==1 && y==0
count=count+1
else x==1 && y==1
count=count
end
else x==1
count=count
end
Everytime it bypasses the count=count+1 statement. As the x and y data are same within while loop. Check the condition
if x == 0
Then the following condition will never be satisfied, because 2nd condition x==1? In the first if condition, count statements are to be executed.
if x ==1 && y==0
count=count+1
else x==1 && y==1
count=count
end
Please confirm the conditions on pen and paper before writing the code. Hope I understand the question,