Code:
int rawvalue;
task main()
{
SetSensor(SENSOR_1,SENSOR_LIGHT);
rawvalue = SENSOR_1;
OnFwd(OUT_A);
until (rawvalue != SENSOR_1);
OnRev(OUT_A);
}
Alright another mindstormer!
I think the above code is what you need. I will explain it line by line:
int rawvalue; - creates a variable named rawvalue in which I will store to reading from sensor_1
SetSensor(SENSOR_1,SENSOR_LIGHT); - Sets sensor port 1 to a light sensor
rawvalue = SENSOR_1; - takes the value of sensor 1 and stores it in the variable
OnFwd(OUT_A) - turns motor A on and runs it forward
until (rawvalue != SENSOR_1); - the program will not continue until the rawvalue doesnot equal sensor 1 (In other words the sensor value has changed from when you last stored it)
OnRev(OUT_A); - once the value of sensor 1 changes motor A will be run in reverse
I hope this helps/is what you needed. If not just respond.