Within main() you'd have something like this:
Code:
while(robot is running) {
if(sensor value > 20) {
turn red on;
turn blue off;
} else {
turn red off;
turn blue on;
}
}
if you don't want the loop to end, you can make it while(true). Configure your light sensor with the Motors and Sensors dialog (I can't remember exactly where it is in the GUI off the top of my head, but it's there), and you can read its value with the SensorValue() function.
Turning red and blue on and off depends on the interface with the light; if it's the same as the standard NXT lamps, set the motor value corresponding to the port (eg. motor[motorA]) to 0 to turn it off, and to any other value up to 100 to turn it on at a given intensity (sign doesn't matter; the intensity at 100 is the same as at -100).