View unanswered posts | View active topics It is currently Fri Oct 31, 2014 3:46 am






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

Joined: Wed Dec 21, 2011 4:22 pm
Posts: 26
Post why wont the code run when i press the bumper?
I'am experimenting to make a autonomous, but i ran across the problem that my autonomous code wont run when the bumper is pressed. I have also tried to place the if statement for if the bumper is touched once on the user control section of the program, but that was a fail.

Code:
task autonomous()
{
 while(true){
  if(SensorValue(bump) == 1){ 
 
  motor[armmotor] = 100;
  wait1Msec(200);
 
    }
  }
   AutonomousCodePlaceholderForTesting();
}


Sat Sep 01, 2012 3:53 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 597
Post Re: why wont the code run when i press the bumper?
We would have to see the rest of the code (including task main) to see if it's even getting to the autonomous task. One thing I might recommend is using functions instead of tasks; generally speaking, they can do what most users need them to without having to worry about CPU micromanagement like you do with tasks.

_________________
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


Wed Sep 05, 2012 9:36 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post Re: why wont the code run when i press the bumper?
My guess is that this was for a competition setting, in the competition template, which is why you're using a task autonomous(). If so, that makes it an OK choice, rather than a function.

Regarding the code, try to remember what each part individually does. A while(true) loop will run forever, because the condition "true" is always true. Nothing like an if statement with a touch sensor will make it stop, because the outer while loop just keeps it running.

My advice is to check out some of the free tutorials we have that will build your programming knowledge: http://www.education.rec.ri.cmu.edu/pro ... index.html

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


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