View unanswered posts | View active topics It is currently Sun Sep 27, 2020 11:20 pm

Reply to topic  [ 2 posts ] 
Line Following.. 
Author Message

Joined: Wed Mar 09, 2011 7:35 pm
Posts: 6
Post Line Following..
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. */
    // 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.

Kyle Johnson
Booker T. Washington's BEST Robotics team.
Tuskegee, Alabama

Fri Mar 11, 2011 2:21 pm
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 409
Post 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?

Jesse Flot
CMU Robotics Academy
ROBOTC Support

Mon Mar 21, 2011 8:41 am
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.