View unanswered posts | View active topics It is currently Mon Dec 22, 2014 9:45 am






Reply to topic  [ 6 posts ] 
follow black line 
Author Message
Rookie

Joined: Tue Feb 27, 2007 10:11 am
Posts: 4
Location: Poland
Post follow black line
Hi ,
I'm beginner and i have a problem

I have to programme a robot who can follow black line.
When he lost black line he must turn left then right to find line.

I began to write program and it looks that:

task main()
{
while(true)

{

if (SensorValue(light) < 40)
{

motor[motorA] = 50;
motor[motorC] = 50;
}

else

{
if (SensorValue(light) > 50)

motor[motorA] = 40;
motor[motorC] = -40;
wait1Msec(250);
}
{
if (SensorValue(light) > 50)
motor[motorA] = -40;
motor[motorC] = 40;
wait1Msec(250);

}
{


if (SensorValue(light) > 50)
motor[motorA] = -40;
motor[motorC] = 40;
wait1Msec(250);
}

{
if (SensorValue(light) > 50)
motor[motorA] = 40;
motor[motorC] = -40;
wait1Msec(250);


}
}
}



And whats wrong?? Pealse for quick ask for ma question.


Tue Feb 27, 2007 10:29 am
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 440
Location: Pittsburgh, PA
Post 
Here's an example of a line following program.

Code:
//*!!Sensor,    S3,          lightsensor, sensorLightActive,      ,              !!*//
//*!!                                                                            !!*//
//*!!Start automatically generated configuration code.                           !!*//
const tSensors lightsensor          = (tSensors) S3;   //sensorLightActive  //*!!!!*//
//*!!CLICK to edit 'wizard' created sensor & motor configuration.                !!*//

// This program uses the light sensor to track the left side of a line

task main()
{
   int threshold = 42;

   while(true)
   {

      if(SensorValue[lightsensor] < threshold)
      {

         motor[motorC]=50;
         motor[motorB]=0;

      }
      else
      {

         motor[motorC]=0;
         motor[motorB]=50;

      }

   }

}


Try that first for the line tracking behavior. You should probably use a timer or an encoder (rotation sensor) in order to track how far it's gone.

In order to use a timer you must first clear it:

Code:
ClearTimer(T1);


and then in a while loop:

Code:
while(time1[T1] < 5000)
{

            //Do something

}


Let me know if you have any more questions!

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Email ROBOTC Support at support@robotc.net to put in a support ticket

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Tue Feb 27, 2007 10:40 am
Profile
Rookie

Joined: Tue Feb 27, 2007 10:11 am
Posts: 4
Location: Poland
Post 
I`m was wrong express , the problem is that ,
robot must search black line in right and left.


Tue Feb 27, 2007 4:10 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 440
Location: Pittsburgh, PA
Post 
astma_pl wrote:
I`m was wrong express , the problem is that ,
robot must search black line in right and left.


I'm sorry, I don't think I understand. Do you want the robot to rotate left, then right, until it finds a black line? What do you want it to do after that?

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Email ROBOTC Support at support@robotc.net to put in a support ticket

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Tue Feb 27, 2007 6:23 pm
Profile
Rookie

Joined: Tue Feb 27, 2007 10:11 am
Posts: 4
Location: Poland
Post 
I wont to do something like this
http://www.youtube.com/watch?v=JNprjLI7294


Thu Mar 01, 2007 9:45 am
Profile
Rookie

Joined: Thu Mar 01, 2007 12:49 pm
Posts: 11
Post 
Quote:
I wont to do something like this
http://www.youtube.com/watch?v=JNprjLI7294


with the “sample program” it should work
Anyway, tomorrow I will work on a different approach to make robot trying to go straight on the line, instead of dancing on it.


Thu Mar 01, 2007 12:54 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.