M8R
August 15, 2017, 12:09pm
#1
Amanpatel998:
Hi guys, I am a new programmer and I need help with my driver control program. I am trying to program my chain bar and it is not working when I program it to the control but it works when I program it directly to the cortex. We have a brand new cortex, controller, motors and motor controllers. We also checked for connection issues but that doesn’t seem to be the problem. Any help is appreciated!
#pragma config(Motor, port2, IntakeR, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port3, IntakeL, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port4, driveR, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port5, driveL, tmotorVex393HighSpeed_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
void mobilelift(int speed)
{
motor[IntakeL] = speed;
motor[IntakeR] = speed;
}
//drive right void
void DriveLeft (int speed)
{
motor[driveL] = speed;
}
//drive left void
void DriveRight (int speed)
{
motor[driveR] = speed;
}
task main(){
while(true){
//Remote Control
//For drive Right
{
DriveRight(vexRT[Ch3]);
//For drive Left
DriveLeft(vexRT[Ch2]);
}
//For mobile
if (vexRT[Btn7DXmtr2] == true)
{
mobilelift(120);
}
else if (vexRT[Btn7UXmtr2] == true)
{
mobilelift(-120);
}
else
{
mobilelift(0);
}
}
}
My fixed version of your code is below, and also the problem with yours may be that you’re using Btn7UXmtr2 (and D), which is only for the partner controller (you can use two controllers on one bot in VEX). If you’re only using one controller, use Btn7U and Btn7D.
#pragma config(Motor, port2, IntakeR, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port3, IntakeL, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port4, driveR, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port5, driveL, tmotorVex393HighSpeed_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#define LIFT_SPEED 120
void mobilelift(int speed)
{
motor[IntakeL] = speed;
motor[IntakeR] = speed;
}
//drive right void
void DriveLeft (int speed)
{
motor[driveL] = speed;
}
//drive left void
void DriveRight (int speed)
{
motor[driveR] = speed;
}
task main(){
while(true) {
DriveRight(VexRT(Ch3));
DriveLeft(VexRT(Ch2));
mobileLift(LIFT_SPEED * (VexRT(Btn7DXmtr2) - VexRT(Btn7UXmtr2)));
}
}