![robotc while loop robotc while loop](https://reader021.cupdf.com/reader021/slide/20171016/5697c0301a28abf838cdaac3/document-1.png)
Repeat while the limit switch is not pressed. Then program the motors to turn off and the LED to turn on until the potentiometer value is less than 2048. Program 2: Program the left and right motors to spin forward until the potentiometer value is greater than 2048. HomeworkProgram 1: Program the right motor to spin forward for 3 seconds, then reverse for 3 seconds, forever. Trainer Notes: Its recommended that you visit the different pages and show trainees the materials that are there.* Trainer Notes: This is how you can get to the VEX Cortex Video Trainer*ĬMU : ROBOTC Forum: your homework and questions here!ROBOTC PLTW Page: Cortex Video Trainer Academy Trainer Notes: Introduce the VEX Cortex Video Trainer Designed to teach behavior based programming using ROBOTC and the VEX Cortex* Repeat while the limit switch isnt pressed. Then program it to spin in reverse until the potentiometer value is less than 2048. While Loop ExercisesExample 3: Program the right motor to spin forward until the potentiometer value is greater than 2048.
#Robotc while loop code#
This will help them refer back to the code later.* Trainer Notes: Recommend that trainees name their finished programs by the title of the slide, including the number and whether it was a group or individual activity. While Loop ExercisesExample 1: Program the green LED to repeatedly turn on for 2 seconds, then off for 2 seconds, forever.Įxample 2: Expand the previous program to loop only while the limit switch is not pressed. Statements that can be only true or false are called Boolean statements, and their true-or-false value is called a truth value. Commands to be RepeatedCommands placed between the curly braces will repeat while the (condition) is true when the program checks at the beginning of each pass through the loop.īoolean LogicDecisions robots make must always based on questions which have only two possible answers: yes or no, true or false.
![robotc while loop robotc while loop](https://jameswmathias.weebly.com/uploads/3/9/1/8/39189329/3785405.png)
The condition is checked every time the loop repeats, before the commands between the curly braces are run.ģ. While the condition is true, the while loop repeats when the condition is false, the while loop ends and the robot moves on in the program. The ConditionThe condition controls how long or how many times a while loop repeats. The word whileEvery while loop begins with the keyword while.Ģ.
![robotc while loop robotc while loop](http://www.cs.csi.cuny.edu/~imberman/csc126/ROBOLABnxt_files/image048.jpg)
There are three main parts to every while loop.ġ. While LoopsA while loop is a structure within ROBOTC which allows a section of code to be repeated as long as a certain condition remains true.