Created
March 11, 2019 12:27
-
-
Save ringodin/13565d55d22124bba47a0d333c005cea to your computer and use it in GitHub Desktop.
This code makes the VEX IQ robot go forward and backwards with encoders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma config(Motor, motor1, leftMotor, tmotorVexIQ, openLoop, encoder) | |
#pragma config(Motor, motor6, rightMotor, tmotorVexIQ, openLoop, reversed, encoder) | |
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// | |
/*------------------------------------------------------------------------------------------------ | |
This program will move the motors forward and backwards | |
ROBOT CONFIGURATION: VEX IQ Clawbot | |
MOTORS & SENSORS: | |
[I/O Port] [Name] [Type] [Location] | |
Port 1 leftMotor VEX IQ Motor Left side motor | |
Port 6 rightMotor VEX IQ Motor Right side motor (reversed) | |
------------------------------------------------------------------------------------------------*/ | |
task main() | |
{ | |
//Reset the current position in the motor encoder to zero. | |
resetMotorEncoder(leftMotor); | |
resetMotorEncoder(rightMotor); | |
//Set motor to run 5000 counts at power level 75. | |
moveMotorTarget(leftMotor, 5000, 75); | |
moveMotorTarget(rightMotor, 5000, 75); | |
//Blocking command prevents program from continuing until movement is complete. | |
waitUntilMotorStop(leftMotor); | |
waitUntilMotorStop(rightMotor); | |
resetMotorEncoder(leftMotor); | |
resetMotorEncoder(rightMotor); | |
moveMotorTarget(leftMotor, -5000, -75); | |
moveMotorTarget(rightMotor, -5000, -75); | |
waitUntilMotorStop(leftMotor); | |
waitUntilMotorStop(rightMotor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment