i am new to robotc and new to c programming. i try to write a program that move my robot just with ch1+ch2 on the remote. the only part of the program that work is (ch2-up + ch1 left) anyone know what am i doing rong?
here is my code :
/* conguration:
left motor= port2 right motor= port3 */
task main () { bMotorReflected[port2] = 1; // change motor 2 diraction because motore 2 is reverse side bVexAutonomousMode = false; //Activates Remote Control Mode
while (1==1) { if (vexRT[Ch1] == 0 && vexRT[Ch2]>0) // if just channel 2 is active up > move forward { motor[port2]= vexRT[Ch2]; motor[port3]= vexRT[Ch2]; } if (vexRT[Ch1] == 0 && vexRT[Ch2]<0 ) // if just channel 2 is active down > move backward { motor[port2]= vexRT[Ch2]; motor[port3]= vexRT[Ch2]; } if (vexRT[Ch2]==0 && vexRT[Ch1] > 0 ) //if just channel 1 is active to right > move right in place { motor[port2]= vexRT[Ch1]; motor[port3]= - vexRT[Ch2]; } if (vexRT[Ch2]==0 && vexRT[Ch1] < 0 ) // if just channel 1 is active to left > move left in place { motor[port2]= vexRT[Ch1]; motor[port3]= - vexRT[Ch2]; } if (vexRT[Ch2]>0 && vexRT[Ch1] > 0 ) //if chanel 2 up and channel 1 right { motor[port2]= (vexRT[Ch2])-((vexRT[Ch2]* vexRT[Ch1])/127); motor[port3]= vexRT[Ch2]; { if (vexRT[Ch2]>0 && vexRT[Ch1] < 0 ) //if channel 2 up and channel 1 left { motor[port2]= vexRT[Ch2]; motor[port3]= (vexRT[Ch2])+((vexRT[Ch2]* vexRT[Ch1])/127); } if (vexRT[Ch2]<0 && vexRT[Ch1] > 0) //if channel 2 down and channel 1 right { motor[port2]= vexRT[Ch2]; motor[port3]= (vexRT[Ch2])-((vexRT[Ch2]* vexRT[Ch1])/127); } if (vexRT[Ch2]<0 && vexRT[Ch1] < 0) //if channel 2 down and channel 1 left { motor[port2]= (vexRT[Ch2])+((vexRT[Ch2]* vexRT[Ch1])/127); motor[port3]= vexRT[Ch2]; } else { motor[port2]= 0; motor[port3]= 0; } } } }
Thanks for the help asher }
Sat May 30, 2009 5:24 am
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
Re: problem with my program
Moved to correct forum.
_________________ | Professional Conduit of Reasonableness | (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots | ROBOTC 3rd Party Driver Suite: [Project Page]
Sat May 30, 2009 8:11 am
jbflot
Site Admin
Joined: Tue May 15, 2007 9:02 am Posts: 409
Re: problem with my program
Try this code out, a slightly modified version from the "Single Joystick Control" Sample program:
Code:
task main() { bMotorFlippedMode[port2] = 1; //Port 2 Motor Direction Flipped bVexAutonomousMode = false; //Activates Remote Control Mode
while (true) //Creates an infinite loop { motor[port2] = vexRT[Ch2]/2 - vexRT[Ch1]/2; //y-axis value: forward/backward motion motor[port3] = vexRT[Ch2]/2 + vexRT[Ch1]/2; //x-axis value: left/right steering //divided by 2 to prevent values over 127 } }
Users browsing this forum: No registered users and 2 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum