timing within a loop

Looks like.

Having said that

if(count == 1) count =0;       // resetting the count

Why check count? You can unconditionally set it zero (either it was already zero, or it's one and you want it to be zero)

Also, given that count can only take two values, shouldn't it be a boolean?