
And if the sensor is touched, we finish the loop. So, while the sensor value is 0 which means that the sensor is not touched we move forward. This operator checks if this value is equal to 0. If the sensor is not touched, then this function will return just 0. If the sensor is touched, it'll return something that is different from 0. Sensor value is a function, that's a function coming from the language and this function does the following thing. So, while sensor value is 0 this means while the sensor is not touched. And if the value of the touch sensor is equal to 0 then we execute line 10 and 11. We're getting the value of the sensor, touch sensor. What we should check is: Is the sensor touched? So we have a function in the language called 'sensor value'. If the condition is not true then the loop will end and line 14 will be executed. While this condition is true these two lines will execute. And it basically works in the following way. There's such a structure in the language called 'while loop'. If the sensor is touched then execute these two lines. While the sensor is touched execute these two lines, move forward. It is not actually possible to do this program in this way because the structure of the language is different but it's very very similar. Then we just set motor on port 2 to equal power 0 and motor on port 3 to equal power 0. Now what we want to do is to execute these two lines while And if the sensor is not touched Motor on port 2 and port 3 just move forward. In the program what we have done previously is just moving forward with these instructions. And for this touch sensor we give the name 'touchsensor'.
#Vex robotc tutorial software
In the software we have to configure the touch sensor and we go to 'Motor and Sensor Setup', then we have the motors in the motors tab configured and in the 'VEX Cortex Digital Sensors' on port 1 because we've connected it on port 1 we add a touch sensor.


Let's go and see how we implement the program. We then implement the program and we're ready to start it. Now the bumper switch is connected to the cortex controller. And I'll connect the bumper switch to digital input 1. Right here on the left side of the controller we have analog and digital inputs. The bumper switch has a cable and this cable must be connected to the digital input of the controller. Now it moves forward until I press the bumper switch. Where the first program will be moving forward until the robot hits something. Let's connect the bumper switch to the cortex controller and implement a few programs to it.
