View unanswered posts | View active topics It is currently Sat Sep 20, 2014 10:03 am






Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6
Trying to get Sonar Sensor to work on Autonomous 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Trying to get Sonar Sensor to work on Autonomous
It looks like you changed the gate2 motor to a servo. Regardless, the problem is still the same that you compared the magnet sensor value to "1" that would never happen.
Code:
if(SensorValue[magnetSensor] > (NO_MAGNET_VALUE + MAGNET_THRESHOLD) || SensorValue[magnetSensor] < (NO_MAGNET_VALUE - MAGNET_THRESHOLD))
   //
   // If the magnetSenor is Inactive gate1 stays closed. If magnetSenor Is Active Servo3 opens, and gate1 closes
   //
   if(SensorValue[magnetSensor] == 1)

{
servo[servo3] = 127;
}
else
{
  servo[servo3] = 0;
}

So the proper code fix should be:
Code:
bool magnetPresent = abs(SensorValue[magnetSensor] - NO_MAGNET_VALUE) > MAGNET_THRESHOLD;
if (magnetPresent)
{
  servo[servo3] = 127;
}
else
{
  servo[servo3] = 0;
}


Wed Dec 14, 2011 5:00 pm
Profile
Rookie
User avatar

Joined: Tue Nov 01, 2011 9:18 pm
Posts: 49
Location: Davenport, Iowa
Post Re: Trying to get Sonar Sensor to work on Autonomous
Thanks i thought i waz the code wrong.


Thu Dec 15, 2011 1:52 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6

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.