Korndog
Rookie
Joined: Fri Apr 26, 2013 11:05 am Posts: 39
|
 Problem with this code
I have been having my students really get into the programming with RobotC for the VEX. I like to make up challenges which reinforce a particular concept. The current challenge is for students to move toward a mostly empty water bottle, pick it up and place them on top of a 2x4. Four 2x4's enclose the arena area in the shape of a square. Some of the problems we have been having focuses around a robot running a piece of code correctly until a certain point. When a piece of code doesn't work, it isn't making sense as to why. We don't receive any error codes when downloading and usually the piece of code worked earlier in the entire program
I have pasted this code and will point out where the robot doesn't work.
#pragma config(Motor, port1, rightMotor, tmotorVex393_HBridge, openLoop, reversed) #pragma config(Motor, port6, claw, tmotorVex393_MC29, openLoop) #pragma config(Motor, port7, arm, tmotorVex393_MC29, openLoop) #pragma config(Motor, port10, leftMotor, tmotorVex393_HBridge, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main() {
motor[claw] = 80; // the claw is opening wait1Msec(500);
motor[leftMotor] = 75; // motor moving forward motor[rightMotor] = 58; wait1Msec(700);
motor[rightMotor]= 0; motor[leftMotor]=0;
motor[claw]=-15; //the claw is closing wait1Msec(1000);
motor[arm]= -40; // the elbow is moving up// ***Here is were the code works properly**** wait1Msec(1000);
motor[rightMotor]=50; //motor moving forward motor[leftMotor]=55; wait1Msec(425);
motor[rightMotor]= 0; motor[leftMotor]=0;
motor[arm] = 25; //the elbow is moving down wait1Msec(500);
motor[arm]=0; wait1Msec(2000);
motor[claw]=80;//claw is opening wait1Msec(500);
motor[leftMotor] = 0; motor[rightMotor] = 0;
motor[leftMotor] = -75; //backing up motor[rightMotor] = -58; wait1Msec(1175);
motor[rightMotor]= 55; //swing turn towrds 2nd bottle motor[leftMotor]=-55; wait1Msec(520);
motor[rightMotor]=50; motor[leftMotor]=55; wait1Msec(475);
motor[rightMotor]=0; motor[leftMotor]=0;
motor[claw]= -80; wait1Msec(2500);
motor[claw] = 0;
motor[rightMotor]=40; motor[leftMotor]=45; wait1Msec(1000);
motor[arm]= 40; // the elbow is moving up// ***This piece of code only moves the arm upward for about 1/10th of a second.** wait1Msec(2000);
}
Thank you.
|