Arduino Encoder Counting to drive DC motor

Hi

How can we use the encoder details to drive a DC motor to a certain position. Let's say I want to drive the motor 1200 pulses clockwise, How I can do that.

I know I can switch the motor ON state and count the number of pulses using Encoder.h library. But how can I compare that value of 1200 counts? Like what kind of statement are we talking about here. Just Confused! :confused:

Regards
KN

if (pulse count < 1200) {...}

or

while (pulse count < 1200) {...}

Okay so in this statement,

if (pulse count < 1200) {...}

or

while (pulse count < 1200) {...}

So this will count the pulses and according to the umber of counts, we can switch the motors on and off?

what do we define in the function above?

You need to make an attempt at writing a program and post your code and your results.

Counting the steps is trivial.
Getting the motor to stop at the right place will be the fun part.

...R