|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Robotc NXT Encoder help
I'm using Robotc for NXT and I'm trying to learn the encoders. So i made a simple forward then left with encoders program. The robot runs the go forwards part but completely ignores the part were it is supposed to turn left. Can anyone help me out and tell me what i did wrong here?
task main() { nMotorEncoder[rightMotor] = 0; //clear the LEGO encoders in motors B and C+ nMotorEncoder[leftMotor] = 0; while (nMotorEncoder[rightMotor] < 1500) //while the encoder wheel turns one revolution (360) { motor[rightMotor] = 50; //turn both motors on at 50 percent power motor[leftMotor] = 50; } motor[rightMotor] = 0; //turn both motors off motor[leftMotor] = 0; wait1Msec(1000); //new line while (nMotorEncoder[leftMotor] < 500) //while the encoder wheel turns one revolution (360) { motor[rightMotor] = 50; //robot will turn left motor[leftMotor] = 0; } motor[rightMotor] = 0; //turn both motors off motor[leftMotor] = 0; wait1Msec(3000); // wait 3 seconds to see feedback from the debugger screens // open the "NXT Devices" window to see the distance the encoder //spins. The robot will coast a little bit. } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|