Skip to content

Instantly share code, notes, and snippets.

@ringodin
Created March 11, 2019 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ringodin/13565d55d22124bba47a0d333c005cea to your computer and use it in GitHub Desktop.
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
#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