View unanswered posts | View active topics It is currently Sat Oct 25, 2014 9:06 pm






Reply to topic  [ 3 posts ] 
Autonomous with light sensors (robot C) 
Author Message
Rookie

Joined: Fri Feb 06, 2009 11:37 pm
Posts: 1
Post Autonomous with light sensors (robot C)
okay, so for our autonomous, we have two light sensors following a line and stopping at the puck rack. but our problem is that the robot just keeps going. we need the robot to stop in three seconds, but wherever we put wait1msec(3000), it ignores the lightsensors. the program just keeps looping. does anyone know how to stop it?? :breakcomputer:


Fri Feb 06, 2009 11:46 pm
Profile
Novice

Joined: Tue Jan 13, 2009 5:22 pm
Posts: 72
Location: USA, Pennsylvania
Post Re: Autonomous with light sensors (robot C)
Here is a simple program that you might have use for.

Quote:
task main()
{
time1(T1) = 0; // Resets the T1 to 0
while(time1(T1) < 3000)condition // While time from T1 is less than 3000 run next
{
if(SensorValue(lightSensor) < 45)// Might need to be changed b/c of the difference between light sensors
{
motor[motorB] = 100;
motor[motorC] = 0;
}
else
{
motor[motorB] = 0;
motor[motorC] = 100;
}
}
}

_________________
We need a Linux Version!


Sat Feb 07, 2009 12:17 am
Profile WWW
Novice

Joined: Fri Oct 24, 2008 8:58 am
Posts: 87
Post Re: Autonomous with light sensors (robot C)
The only thing I would add is that its probably best to have a small delay every time through the loop. Other wise you're not giving the system any time to respond (and potentially not giving other tasks time to process)

Code:
task main()
{
 time1(T1) = 0; // Resets the T1 to 0
 while(time1(T1) < 3000)condition // While time from T1 is less than 3000 run next
 {
   /* Check your sensors here and follow the line */

   wait1Msec(10);   // Wait 10 msec until we check sensors again
 }
}


if your short on timers (since there's only 4) you could easily use a variable counter in this scenario.

Code:
task main()
{
  int loopCount = 0;

  while(loopCount < 300) // 300 loops of 10 msec = 3000msec = 3 sec
  {
    /* Check your sensors here and follow the line */

    wait1Msec(10);   // Wait 10 msec until we check sensors again
    loopCount += 1;
  }
}


Sat Feb 07, 2009 11:00 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.