ROBOTC.net forums
http://robotc.net/forums/

My Code won't Compile...
http://robotc.net/forums/viewtopic.php?f=1&t=10269
Page 1 of 1

Author:  electrps [ Thu Jan 15, 2015 5:30 pm ]
Post subject:  My Code won't Compile...

Hey everyone. I'm new to RobotC and I got a tutorial from FTC Mentor Training. I followed it exactly but everytime I press download and compile it wont work. Here is the code:


task main()
{
int dValue = 15; // motor power
int threshold = 50; // light sensor threshold
int mValue = 30;

while(SensorValue(LightSensor) > threshold)
{
motor[motorD]= dValue;
motor[motorE]= dValue;
}

motor[motorD]=0;
motor[motorE]=0;
wait1Msec(500);

while {SensorValue(LightSensor) < threshold)
{
motor[motorD] = mValue;
motor[motorE] = mValue* (-1);
}

motor[motorD] = 0;
motor[motorE] = 0;
}

Any help would be appreciated.

Author:  JohnWatson [ Thu Jan 15, 2015 6:13 pm ]
Post subject:  Re: My Code won't Compile...

Without seeing the rest of the code, it will be hard to tell if it's a configuration issue, but...

Code:
while {SensorValue(LightSensor) < threshold)


Note the first curly brace { after the while loop. This should be a parenthesis instead:

Code:
while (SensorValue(LightSensor) < threshold)


Try that and let us know if it fixes the issue you're running into.

Author:  zoan [ Sun Feb 15, 2015 6:21 pm ]
Post subject:  Re: My Code won't Compile...

You cannot put SensorValue(LightSensor) because this should be a port number and you should initiate what sensors you are using in the beginning by using SensorType[S1] = sensorLightActive;
or just replace the S1 part with whatever port you are using.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/