View Single Post
  #13   Spotlight this post!  
Unread 08-05-2014, 22:14
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: How to loop peices of code forever?

When I program in VEX, RobotC, I create a main loop. This loop will execute until it is killed somehow, or the break statement is used. Basically, you have an infinite loop (while(true) {...}) and that holds all your code.

In this loop, you only execute the command ONCE. Basically, the program loop will constantly check all inputs. If it notices any of the inputs high, for example, using a joystick, the program branches into another function, that runs the mechanism once. For servos, this is different. You assign a servo a position and it will stay there. You only signal the servo when you change positions (or not).

This way, everything will run together constantly.

It is sad that the VEX cortex does not support threading or tasks . It would be nice to run tasks parallel to each other. Does anyone by chance know how to bypass RobotC and actually access C10 (I think that's what it runs)? We are doing VEX robotics in eng. class, but I want to do things that are a bit harder!