-2

Can someone please give the code which can be used to rotate the dc motor a specific number of rotations like 2 rotations or 5 rotations. I'm using arduino uno board.

2
  • 6
    I'm voting to close this question as off-topic because this isn't a gimme da code site. May 21 '17 at 12:00
  • 1
    Hi @Rohit and welcome to the Arduino SE community. Unfortunately your question doesn't meet our quality standards. Please edit and improve it. How to ask
    – sa_leinad
    May 21 '17 at 16:25
2

You can't. You either have to attach a sensor to the motor shaft to measure the numbers of rotations or use a stepper motor.

0

No! That is not how motors work.

If you need precision control you need to use a stepper motor or servo.

You could implement some solution with a geared motor and position sensor, but this really only works (imprecisely) with a slow rotation speed.

-1

Can someone please give the code which can be used to rotate the dc motor a specific number of rotations like 2 rotations or 5 rotations.

fairly simple:

rotation_count = 0; //initialize rotation counter
motor_on();  //turn on the motor
while (rotation_count < DESIRED_COUNT) {
  rotation_count = count_rotation(); //update rotation count
};
motor_off(); //turn off the motor

Not the answer you're looking for? Browse other questions tagged or ask your own question.