View Single Post
  #3   Spotlight this post!  
Unread 30-08-2003, 16:47
rlowerr_1's Avatar
rlowerr_1 rlowerr_1 is offline
Registered User
#0930 (M³)
 
Join Date: Jan 2002
Location: Wisconsin
Posts: 61
rlowerr_1 is an unknown quantity at this point
Send a message via AIM to rlowerr_1
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.
__________________
Ryan Lowerr - Ryan@lowerr.com
Check out my LEGO creations here!