I am trying to get this to loop back to the top but instead it will only do the open and then close and then it will stop the code and i have to re run it but what i want it to do is.
If you want the code to run continually, you will need to put it inside some sort of loop. In the example below, and infinite while loop is used but there are other methods that you can use:
while(true)
{
//All of the code you want to loop
}
This will continually loop through the code that you specify, over and over again, until the Cortex is turned off. You can learn more about loops in our Video Curriculum Trainer (http://www.education.rec.ri.cmu.edu/products/teaching_robotc_cortex/index.html), with the first introduction of loops found under the ‘Movement → Shaft Encoders → Forward for Distance’ section.