How to make DC motor move back and forth at a particular set angle

Hello Arduino family, I have been working on part of the ventilator project which requires making the motor shaft move back and forth at a particular angle. For example, if I set the angle at 30 degrees then the motor shaft should go to 30 degrees and move back to 0 degrees. The motor I am using is in this link Together with it, I am using solo 30A Roboclaw to read encoder pulse and control the motor. The Roboclaw I am using can be found at this link Roboclaw Solo 30A, 34VDC Motor Controller

My progress so far:

  • I am able to motor move back and forth using delay();
  • I am able to get speed and encoder pulse from the motor;

Any help given will be appreciated. :slight_smile:

Thank you

May I offer a couple suggestions?

Try a servo motor, like the ones in a 3D printer or a CNC machine. With the right logic, they know where they are.

Or try putting some switches along your motor's travel path so your controller knows where things are at any one time. Take a look at DIY wind direction devices work.

Also, at power up, the motor needs to know where zero is to know anticipated travel distance. There is no guarantee that at a power failure, the motor will be at zero.

I'd like to know what you come up with.

Hopefully this isn't too late, but I agree with @billz1 to consider servo motors that will have already solved the positioning issue. There are analog hobby servos and then more expensive digital servos that can receive exact position commands from the Arduino over serial.

I've worked with these servos before and they come in a large range of sizes. Would something like that work in a larger size?


Your topic was Moved to it's current location / section as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

A servo us well worth a look - that motor does 28rpm so won’t do the job

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.