Robotc api code#
stopmotor(motor) Parameters: motor Acceptable Motors for motor: MOTOR ports 1 through 10 (and your names for them given in Motors and Sensors Setup.) startmotor() wait() stopmotor() This snippet of code will run the motor in motor-port 6 at speed 95 for 1.0 seconds and then stop it. This snippet of code will run the motor in motor-port 8 at speed -32 for 0.5 seconds and then stop it. The default motor-port is port6 and the default speed is 95 for startmotor(). startmotor() wait() stopmotor() startmotor(port8, -32) wait(0.5) stopmotor(port8) This snippet of code will run the motor in motor-port 6 at speed 95 for 1.0 seconds and then stop it. startmotor(motor, speed) Parameters: motor, speed Acceptable Motors for motor: MOTOR ports 1 through 10 (and your names for them given in Motors and Sensors Setup.) Valid Range Values for speed: -127 (reverse) to 127 (forward) where 0 is stop. ROBOTC Natural Language - VEX Cortex Reference 1ΔΆ Start Motor Set a motor to a speed. setservo(port8, 37) This snippet of code will set the servo on motor-port 8 to position 37. The default motor-port is port6 and the default position is 0 for setservo(). setservo() This snippet of code will set the servo on motor-port 6 to position 0 (center). setservo(servo, position) Parameters: servo, position Acceptable Motors for servo: MOTOR ports 2 through 9 (and your names for them given in Motors and Sensors Setup.) Valid Range Values for position: -127 to 127. Movement Functions: Set Servo Set a servo to a desired position. This will automatically set up the motor and sensor ports to match those of a default Recbot. This snippet of code will set the robot type to recbot.
![robotc api robotc api](https://image.slidesharecdn.com/introtorobotc1-130320232643-phpapp02/95/intro-to-robotc-30-638.jpg)
You must manually set the motors and sensors in the 'Motors and Sensors Setup' menu. robottype() robottype(recbot) This snippet of code will set the robot type to none by default, skipping the setup process. swervebot - sets the motors and sensors to match a default Swervebot. robottype(type) Parameters: type Valid Robot Types for type: none - this will not set up any motors and sensors for you (this is the default.) recbot - sets the motors and sensors to match a default Recbot.
![robotc api robotc api](https://www.vexforum.com/uploads/default/original/3X/e/c/ecbb0e55d17a69e7ded3c43c9b56f0d2b08e3df0.jpeg)
Note that not including this command defaults to "robottype(none) " Also please note that this command should be the first thing in your "task main()". 1 Setup Functions: Robot Type Choose which robot you want to write a program for.