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

Mismatched typedefs error.
http://www.robotc.net/forums/viewtopic.php?f=63&t=11257
Page 1 of 1

Author:  Krow [ Thu May 21, 2015 10:06 am ]
Post subject:  Mismatched typedefs error.

Hi,

I was wondering why I was getting a typedef error for my code.
Code:
task main()
{
startMotor(flashlight, 127);
int count = 0;
while(count < 23)
{
startMotor(motor1, 15);
wait(.3);
stopMotor(motor1);
wait(3);
count = count + 1;
}
clearTimer(T1);
while(timer1 <120000)
{
if(lightSensor <= 700)
{
   startMotor(servoMotor, 127);
   wait(2);
   startMotor(motor2, 20);
   wait(.35);
   stopMotor(motor2);
   wait(4);
}
else(lightSensor >=875);
{
   startMotor(servoMotor, -127);
   wait(1);
   startMotor(motor2, 20);
   wait(.35);
   stopMotor(motor2);
   wait(4);
}
}
}


The typedef errors I'm getting read
Code:
*Warning*:Mismatched typedefs. Converting typedef 'long' to typedef 'TTimers', value '0x1D4C0'
*Warning*:Mismatched typedefs. Converting typedef 'short' to typedef 'tSensors', value '0x036B'
*Warning*:Mismatched typedefs. Converting typedef 'short' to typedef 'tSensors', value '0x02BC'


I'm trying to code a marble sorting robot for my Project Lead the Way class, and I can't seem to get it to work. Theoretically, the code should be correct. Is there something I'm doing wrong?

Author:  JohnWatson [ Thu May 21, 2015 10:52 am ]
Post subject:  Re: Mismatched typedefs error.

Your code is very close, but it is coded incorrectly on two major aspects; accessing the timers, and accessing the sensors. For example:

Code:
   while(timer1 <120000)


To access a timer's value, you should instead use the "time1[nameOfTimer]" command, like this:

Code:
   while(time1[T1]<120000)


Likewise, you need to make sure you are using the 'SensorValue' command to access the values of your sensors. This line of code:

Code:
if(lightSensor <= 700)


should instead be:

Code:
if(SensorValue(lightSensor) <= 700)


Once you make those changes (as well as the changes to any other places that you access sensors/timers) your code should be good to go from a syntax standpoint.

Author:  Krow [ Fri May 22, 2015 9:42 am ]
Post subject:  Re: Mismatched typedefs error.

Thank you so much! It worked like a charm! ^_^

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