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

Need help with programmimg an IR seeker
http://www.robotc.net/forums/viewtopic.php?f=1&t=5465
Page 1 of 1

Author:  itsBenton [ Thu Feb 07, 2013 8:55 am ]
Post subject:  Need help with programmimg an IR seeker

The competition is less than a week away and i need to program an ir sensor for the robot. It moves towards the beacon but i cant it to stop. I need help! thanks, Benton.

Author:  mightor [ Thu Feb 07, 2013 12:42 pm ]
Post subject:  Re: Need help with programmimg an IR seeker

Could you please post the code you have so we can see what might be wrong with it?

Also, please don't send PMs to people to ask for help, you'll often get much better help if you post on the forum.

= Xander

Author:  itsBenton [ Thu Feb 07, 2013 5:55 pm ]
Post subject:  Re: Need help with programmimg an IR seeker

Code:
task main()
{
  while(1 == 1)
  {
    if(SensorValue[IRSeeker2] == 0)
    {
       motor[RightDrive] = 80;
      motor[LeftDrive] = -80;
    }
    if(SensorValue[IRSeeker2] == 5)
    {
      motor[RightDrive] = 0;
      motor[LeftDrive] = 0;
    }
    if(SensorValue[IRSeeker2] == 5)
    {
       motor[Lift] = -60;
       wait1Msec(1000);
    }
    if(SensorValue[IRSeeker2] == 5)
    {
    motor[RightDrive] = 90;
    motor[LeftDrive] = 90;
    }
    if(SensorValue[IRSeeker2] == 5)
    {
       motor[RightDrive] = 0;
       motor[LeftDrive] = 0;
    }
  }
}

Author:  itsBenton [ Thu Feb 07, 2013 5:56 pm ]
Post subject:  Re: Need help with programmimg an IR seeker

and ok, thank you

Author:  mightor [ Fri Feb 08, 2013 12:45 am ]
Post subject:  Re: Need help with programmimg an IR seeker

First of all, you didn't include the whole program, there are no #pragma lines in here. Next time, make sure you put them in too. Second, make sure you surround your code with [ code] [/ code] tags (without the spaces). It will make your code much more readable.
There is nowhere in your robot where you tell it to stop when you're a certain distance away from the object. I have a few questions for you, and you really need to think about them:
* What happens when the object is straight in front (5).
* What happens when the object is to the left (ir seeker returns 1 or 9, depending on how the sensor is mounted)
* What happens when it's a little bit to the right (ir seeker returns 3 or 7, depending on how the sensor is mounted)

To be able to successfully use a sensor, it is important that you understand its behaviour. Reread the page here, especially the introduction part: http://www.hitechnic.com/cgi-bin/commer ... ey=NSK1042

Regards,
Xander

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