something wrong in program logic.Please help

hi,
I am working on a project for which I need to check if blue color is detected.If detected THEN ONLY readings of ultrasonic sensor will be printed on hyper terminal and sent serially for further processing.

Now I have few issues:

Issue 1: I am checking if blue color is detected through if condition.

if(sensorValue>=1)
{…


}

since mostly output of color sensor module is below 1 volt when blue color is held against sensor. But then output was not correct…something was wrong.

so i observed output of sensor on serial port and then accordingly set threshold.

if (sensorValue<=100)
{…


}
and THIS worked…!!! I dont know …but I ahve feeling that something is wrong. Please help.

2)Issue 2: I wan to detect blue color and THEN start taking readings of ultrasonic sensor and next time when it encounters blue again stop taking readings for ultrasonic sensor…But current code scans for blue color every time and then only takes readings from ultrasonic sensor.

How to fix this??
I am attaching code

blue_ultra_edited15022015.txt (1.25 KB)

sorry... question not for this forum..posted at wrong place.