In order to successfully complete the coding challenges that await, you will need to understand programmatic "loops" and incorporate them into your program.
In RobotC they are called "while loops" which means they are continually in effect "while" your program is running, you write the "loop" code one time and then it is referenced in your program forever - very useful!!
WHILE LOOPS
Have a look at the two examples below:
1. The Washing Machine Loop
2. The Light Switch
Open the PLTW test program template, and write a program for EACH of the examples below.
Save them as the Washing Machine and the Light Switch
Notes:
The "syntax" - or where you place the curly brackets and the while loop is very specific and important
You will need to REPLACE your port and components names with those in the examples - go to your MOTOR SENSORS and SET UP page to do this...
Try to get this one to work....this will have motor run only when the "limit switch" is held down (=1).. then when you release an LED will come on... I think it is missing a wait command and then a turn the light off statement - but test it to find out..
...
Here is another one to try..this should run forever, and only have the motor turn "ON" when
the limit switch is held down - it should stop when the limit switch = = 0, meaning not held
Here is a good video on using While Loops with If and Else Statements
Support Links:
Here are some great links to the VEX site that have all sorts of help -