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

Line Follower C#, I need help!
http://robotc.net/forums/viewtopic.php?f=1&t=8836
Page 1 of 1

Author:  Vestal [ Tue May 20, 2014 4:05 pm ]
Post subject:  Line Follower C#, I need help!

I can't make a line following bot using a light/colour sensor in C# any help with the code for a robot to follow a black line?
I was thinking about an if statement, such as; if colorsensor = black; motorpair mvefwd.
something along those lines, if i'm being vague its because i'm a beginner at C#, sorry.

Author:  mightor [ Wed May 21, 2014 12:19 am ]
Post subject:  Re: Line Follower C#, I need help!

I'm afraid that this is not a C# forum but ROBOTC. The two are very different. What robotics platform are you using? Maybe you can ask on the forums for that specific platform.

= Xander

Author:  sasha.chekel [ Mon May 26, 2014 7:55 pm ]
Post subject:  Re: Line Follower C#, I need help!

This is a code for LEGO Mindstorms and 2 Light Sensor configuration:

task main()
{
int err;
int u;
int k=9.5;
int v=35;
int es=SensorValue[S1]-SensorValue[S2];
while(nNxtButtonPressed!=3)
while(true)
{
err=SensorValue[S1]-SensorValue[S2]-es;
u=k*err;
motor[motorB]=v+u;
motor[motorC]=v-u;
}
}

Author:  BurningLights [ Mon May 26, 2014 8:46 pm ]
Post subject:  Re: Line Follower C#, I need help!

sasha.chekel wrote:
This is a code for LEGO Mindstorms and 2 Light Sensor configuration:

task main()
{
int err;
int u;
int k=9.5;
int v=35;
int es=SensorValue[S1]-SensorValue[S2];
while(nNxtButtonPressed!=3)
while(true)
{
err=SensorValue[S1]-SensorValue[S2]-es;
u=k*err;
motor[motorB]=v+u;
motor[motorC]=v-u;
}
}


I'm not sure what your code should be doing that it's not doing, but I can immediately spot an error. You're missing a pair of brackets for the while(nNxtButtonPressed != 3). Change that line to
Code:
while (nNxtButtonPressed != 3) {}

and that should fix that problem.

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