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

Line Following..
http://robotc.net/forums/viewtopic.php?f=11&t=3109
Page 1 of 1

Author:  yuukikaihou [ Fri Mar 11, 2011 2:21 pm ]
Post subject:  Line Following..

Code:
task main()
{
#pragma config(Sensor, in1,    lineFollowerRIGHT,   sensorLineFollower)
#pragma config(Sensor, in2,    lineFollowerCENTER,  sensorLineFollower)
#pragma config(Sensor, in3,    lineFollowerLEFT,    sensorLineFollower)
#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop)


task main()
{
  wait1Msec(2000);          // The program waits for 2000 milliseconds before continuing.

  int threshold = 505;      /* found by taking a reading on both DARK and LIGHT    */
                            /* surfaces, adding them together, then dividing by 2. */
  while(true)
  {
   
    // RIGHT sensor sees dark:
    if(SensorValue(lineFollowerRIGHT) > threshold)
    {
      // counter-steer right:
      motor[leftMotor]  = 63;
      motor[rightMotor] = 0;
    }
    // CENTER sensor sees dark:
    if(SensorValue(lineFollowerCENTER) > threshold)
    {
      // go straight
      motor[leftMotor]  = 63;
      motor[rightMotor] = 63;
    }
    // LEFT sensor sees dark:
    if(SensorValue(lineFollowerLEFT) > threshold)
    {
      // counter-steer left:
      motor[leftMotor]  = 0;
      motor[rightMotor] = 63;
    }
  }

I tried using this samle code on the robot, it didn't work, it just went forward, and a slight turn here and there, can anyone help me? I'm using a black line on white paper. My only guess is that the sensors aren't low enough.

Thanks in advance.

Author:  jbflot [ Mon Mar 21, 2011 8:41 am ]
Post subject:  Re: Line Following..

Hi Kyle,

The problem may be that the threshold (the value that the robot uses to decide if it's over the black line or the white surface) used in the sample program may not be correct for your lighting environment. Have you calculated your own threshold, using the values from your sensors?

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