13.07.2015 Views

Programming - VEX Robotics

Programming - VEX Robotics

Programming - VEX Robotics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

programmingautonomous programsunderstanding bump sensor test code, continuedBCComments - Comments allow you to leave notes to yourself and othersabout your code. These comments do not affect how the program runs, butare very important in helping others to understand your code (and remindingyourself, if you revisit a program several weeks or months later).While Loops - This is a block of code that willrepeat itself as long as the condition inside theparentheses is true. The condition in the whileloop in this program asks whether (loop == 1),i.e. whether the value of the variable "loop" isequal to 1. The code inside of this loop will runover and over as long as "loop" is equal to "1".As it turns out, the variable "loop" was set to astarting value of 1 in the variable window (seeprevious page). Since we never change the valueof the "loop" variable, we can reason that it willalways be equal to 1, and so this while statementwill repeat its code forever (or at least as long asthe robot is on.)DPrint to Screen - This is the code that allows you to seeinformation in the terminal window. If you double click on theicon next to the PrintToScreen statement, you will see the"Print To Screen"configuration menu.The "Message" field lets you specifytext which you would like to displayin the terminal window.The optional “Variable” field lets you display the currentvalue of a variable in the printed line (it will appear atthe end, after the “Message” text). The “Variable” dropdown menu lets you choose which variable to display. The“directive” menu tells the computer how to display thevariable’s value. %d tells the computer to use a decimalformat, which works well for int-type variables like bumper.The “typecast” menu specifies the type of the variable. Thisshould usually match the type of variable you specified.01/31/05Inventor’s Guide8 • 37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!