Following the line error

2 replies [Last post]
Owl
Title: NooBot
Joined: 01/22/2012
Posts:
BotPoints: 13
User offline. Last seen 10 years 33 weeks ago.

This is a portion of my program that is suppose to follow a line until the counter position is over 4000. I keep getting the error
"DorothyTest.c:108:5: error: lvalue required as left operand of assignment" on the line that says "if (get_motor_position_counter(0) > 4000) finish=1;", and I don't know what to do. Could you help me?

while (finish == 0)
{
int threshold=512; // set threshold
int high=600,low=400; // wheel speeds for arc radius
while (analog10(7) > threshold) { // continue until not dark
mav(0,low); mav(3,high); // arc left
while (analog10(7) <= threshold){ // continue until dark
mav(0,high); mav(3,low); // arc right

if (get_motor_position_counter(0) > 4000) finish=1;
}
ao();
printf("done\n");
return 1;
}
}
}

Jeremy Rand
Jeremy Rand's picture
Title: Botball Youth Advisory Council
Joined: 04/03/2009
Posts:
BotPoints: 1168
User offline. Last seen 7 years 19 weeks ago.

Where does the variable finish show up elsewhere in the code? It looks like there might be something funky with that variable.

-Jeremy Rand
Senior Programmer, Team SNARC (2012-2013), Norman Advanced (2010-2011), Norman HS (2008-2009), Norman North (2005-2007), Whittier MS (2003-2004)
2012-2013 VP of Tech, 2011 President, Botball YAC (2009-2013)
Mentor, Alcott and Whittier MS

Marty Rand
Marty Rand's picture
Title: Botball Youth Advisory Council
Joined: 07/04/2009
Posts:
BotPoints: 253
User offline. Last seen 8 years 6 weeks ago.

You could just make the while loop say:

  1. while (get_motor_position_counter(0) < 4000)

and take out the if statement. That would probably fix the error, and simplify the code.

-Marty Rand
{
Senior programmer at Norman Advanced Robotics

Former senior programmer at Whittier Middle School

Youth Advisory Council

All around nerd
}