View unanswered posts | View active topics It is currently Thu Apr 24, 2014 11:03 pm






Reply to topic  [ 3 posts ] 
why wont the bumper run my code when i press it? 
Author Message
Rookie

Joined: Wed Dec 21, 2011 4:22 pm
Posts: 26
Post why wont the bumper run my code when i press it?
why wont my autonomous run when I press the bumper?

task autonomous()
{
Code:
 int threshold = 1000; 
     
      ClearTimer (T1);
      while(time1[T1] < 1000){


Code:
// RIGHT sensor sees dark:
    if(SensorValue(rightline) > threshold)
    {
      // counter-steer right:

      motor[frontleft] = 63;
      motor[backleft] = 63;
      motor[frontright] = 0;
      motor[backright] = 0;
     
    }


Code:
 // CENTER sensor sees dark:
    if(SensorValue(center) > threshold)
    {
      motor[frontleft] = 63;
      motor[backleft] = 63;
      motor[frontright] = 63;
      motor[backright] = 63;
    }


Code:
// LEFT sensor sees dark:
    if(SensorValue(leftline) > threshold)
    {
      // counter-steer left:
      motor[frontleft] = 0;
      motor[backleft] = 0;
      motor[frontright] = 63;
      motor[backright] = 63;
    }


Code:
 motor[frontRight] = 100;
      motor[backRight] = 100;
      motor[frontLeft] = -100;
      motor[backLeft] = -100;
     wait1Msec(450);


}
AutonomousCodePlaceholderForTesting();
}

Code:
task mian(){

     if(SensorValue(bump) == 1){
       StartTask(autonomous); 
     }

}


Sat Sep 01, 2012 2:54 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 537
Post Re: why wont the bumper run my code when i press it?
Task main is misspelled (task mian). Try to see if that solves it for you, if not let us know.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Sep 04, 2012 10:46 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: why wont the bumper run my code when i press it?
Think about how your robot "flows" through the program. Your robot's starting point is always "task main()".

Based on your code in task main, the robot will check ONCE if "bump" is pressed, then move on. There's nothing else in your code, so the program ends and the robot does nothing.

What you want to do is wait until the touch sensor is pressed, not just check if it is pressed and move on. You can do this by changing your logic based off of the following pseducode;

Code:
while(the touch sensor is NOT pressed)
{
...do nothing
}
StartTask(autonomous);

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Mon Oct 01, 2012 2:52 pm
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.