Simple Robotc photoresistor program- how to make it self-calibrating?

Hello,
I am relatively new to programming, and I’ve been doing Robotc programming with VEX in my PLTW Principles of Engineering high school class. My group and I had an assignment to create a soccer goal with the VEX parts we have in class that makes a red light blink for 10 seconds when a ball goes into the goal, but not when anything else does.
Obviously the best way to do this would be to put a transponder in the ball, but we don’t have the materials for that. We decided to get a light up bouncy ball from Party City and put light sensors in the goal.
I can actually paste our program into this thread tomorrow at school, but for now the best I can do is a photo.
If we wanted to make the program self calibrate, so it took an initial reading of the ambient light in the room and then went off if either sensor value dropped below that baseline, how would we do that?
Thanks!
Soccer goal program.jpg

I believe with something like this

int ambientLight1, ambientLight2;

ambientLight1 = SensorValue[lightSensor1];
ambientLight2 = SensorValue[lightSensor2];

while(1){
     if(SensorValue[lightSensor1] < ambientLight[1] || lSensorValue[lightSensor2] < ambientLight2)
          flashLed();
}

The problem is that the light sensor reading probably bounces around a bit, so you would have to check for a significant drop.
Like this maybe

int ambientLight1, ambientLight2;

ambientLight1 = SensorValue[lightSensor1]-100;
ambientLight2 = SensorValue[lightSensor2]-100;

while(1){
     if(SensorValue[lightSensor1] < ambientLight[1] || SensorValue[lightSensor2] < ambientLight2)
          flashLed();
}

I don’t know if a drop of 100 is reasonable or too small/big. Even better might be to read the ambient light multiple times over a couple seconds and average the values; then see if the reading differs significantly from that average.

Thanks. We’ll try that and I’ll post any updates or questions.
Here’s the program text:
#pragma config(Sensor, in1, LightSense, sensorReflection)
#pragma config(Sensor, in2, LightDumb, sensorReflection)
#pragma config(Sensor, in3, LightSense2, sensorReflection)
#pragma config(Sensor, dgtl1, LEDr, sensorLEDtoVCC)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

/*
Project Title:
Team Members:
Date:
Section:

Task Description:

Pseudocode:

*/

task main()
{
while(1 == 1)
{
if (SensorValue[LightSense]<600 || SensorValue[LightDumb]<600 || SensorValue[LightSense2]<600) //Program begins, insert code within curly bracesturnLEDOff(LEDr);wait(1);
{
turnLEDOn(LEDr);
wait(1);
turnLEDOff(LEDr);
wait(1);
turnLEDOn(LEDr);
wait(1);
turnLEDOff(LEDr);
wait(1);
turnLEDOn(LEDr);
wait(1);
turnLEDOff(LEDr);
wait(1);
turnLEDOn(LEDr);
wait(1);
turnLEDOff(LEDr);
wait(1);
turnLEDOn(LEDr);
wait(1);
turnLEDOff(LEDr);
}
}
}

The sensor values in that program are different than the ones in the picture because we experimented with values and found what worked best.