Quote:
|
Originally Posted by Ctx32
Thats my problem, How do you tell the motor to go forward say 90 clicks?
Is this how: Begin - Start Encoder - Get encoder - motor module clockwise
If -encoder ==90 - stop motor.
Is this correct?
and how do you reverse it?
I'm sorry I'm really lost.
Thanks for your help.
Calvin
|
That is basically correct. Start the encoder when you want it to start. Inside some sort of loop, get the encoder value. Compare that to 90. If it's less, drive the motor forward. Stop it when it gets to 90 or above.
The encoders do not detect direction. So no matter what way it moves, the value will increase. Depending on how your code is set up, to reverse it, you have two choices. 1) reverse the motor direction and keep counting the encoder until it hits 180. Then stop. 2) reset the encoder and in a separate loop, do the same thing as forward, except you need to reverse the motor direction.
Try this...
create a variable, count = 0
Start Encoder
While (count <= 90)
Set motor forward
Set motor to neutral
Stop Encoder
Start Encoder
While (count <= 90)
Set motor reverse
Set motor to neutral