Does anyone know how to make sections of code repeat themselves? Or do you just have to keep re-writing the section of code over and over and over and over and over…?
make a while loop and put the repeating stuff in it (while==1) Or (1==1)
or if you want to repeat a certain number of times
int repeatThisNumberOfTimes = 5; //this is how many times to repeat
for (int i = 0; i < repeatThisNumberOfTimes; i++){
//code here
}
in this case the best resource would be to read the easyC help files (or MPLAB guide) on “for” and “while” loops
thanks guys that helped a lot.
You can also create user functions which I’m guessing is what you really want to do.
Say I want to have the robot back up and turn left every once in a while. So I right click on functions, click “create new function”. Now in that I place the back up and turn left blocks. Now every time I want the robot to back up and turn left I place that “block” or function into the code.