View unanswered posts | View active topics It is currently Thu Jul 24, 2014 4:53 pm






Reply to topic  [ 4 posts ] 
Line Follower C#, I need help! 
Author Message
Rookie

Joined: Tue May 20, 2014 3:57 pm
Posts: 1
Post 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.


Tue May 20, 2014 4:05 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3162
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed May 21, 2014 12:19 am
Profile WWW
Rookie

Joined: Mon May 26, 2014 7:30 pm
Posts: 1
Post 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;
}
}


Mon May 26, 2014 7:55 pm
Profile
Online
Novice

Joined: Sat Aug 31, 2013 9:15 am
Posts: 92
Post 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.

_________________
Burning Lights Programming
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
Check out our team website at http://cof7468.weebly.com/.


Mon May 26, 2014 8:46 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.