|
Analog vs. DigitalDigital ports are used for sensors that read only two values, true (1) or False (0). Whereas analog can distinguish between many different values. Such as a reading from a potentiometer or an encoder.
Some basic Code descriptionsTo the right is a short code that was written for out vex test bed.
There are a number of different functions in the code. They are as follows: task main() : this determines what the robot is going to do as in all code that controls the robot need to be within this function. While ( 1==1) : This statement tells the robot that this a loop that is always true and anything within this loop will continuousy run. void LEDControl () : This defines a function. It is like a variable in the sense that if you do not want to type in the 5 lines of code over and over again you can just define multiple lines of code as a single line of code to save time while coding multiple lines when calling upon that function. if else statments : These are your true or false statments. This meaning, in the code to the right, that as long as the [bumpSwitch] sensor is pressed ( == 1) then the led will turn on. Else means that as long as [bumpSwitch] does not equal 1 that the led will turn off. turnLEDOn (green) / turnLEDOff (green): Pretty self explanitory that these tell an led, of the name green, to be turned on or off. Whether it is on or off is determined by the if/else statement. Notes:The task main(), while (1==1), and if/else statments all have { to begin the function and } to close the function.
you need a ; after every command in order to make the code work properly. All code is case sensitive and syntax sensitive. |
Input or Output?An input device is:
Any sensor that takes information from the outside world and sends values to the program. An Output device is: Any device that takes information from the code and uses it to perform a function. Such as a motor does get information it only recieves it and then performs the indicated operation. |
Create a free website with
Weebly