loopin and controlling rotation ,direction od dc motor

hii
I am new here with Arduino,i want to control a dc motor to make a climbing robot.
so i want to make the motor rotate 5 times in forward direction then 5 times in backward direction like a loop.when i pre the forward button it must move like this simultaneously. also I want to control this with Bluetooth module.

i don't no how to program this.

i have L293D motor driver,Arduino Leonardo, 12v dc motor,Bluetooth module

Have you got any way of measuring the rotation of the motor so that you can know when it has rotated 5 times ?

Hii
i am new with arduino and i know only little c language, so can u friends help me to program arduino..?

I want to rotate a dc motor for 5 times in forward direction and 5 time times in backward direction..
this must run until i press forward button it must rotate forward and backward like a loop.
I also want to control it with Bluetooth module and mobile
I have an Arduino Leonardo,HC-05 Bluetooth module,L293D motor driver

How to program this..

Why have you posted the same question twice ?

First of all you will need a motor control shield for your Arduino.

Here are a couple of options:

And the following is one of the example sketches from the Adafruit motor shield library.....the code should be fairly self explanatory.

// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

#include <AFMotor.h>

AF_DCMotor motor(4);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");

  // turn on motor
  motor.setSpeed(200);
 
  motor.run(RELEASE);
}

void loop() {
  uint8_t i;
  
  Serial.print("tick");
  
  motor.run(FORWARD);
  for (i=0; i<255; i++) {
    motor.setSpeed(i);  
    delay(10);
 }
 
  for (i=255; i!=0; i--) {
    motor.setSpeed(i);  
    delay(10);
 }
  
  Serial.print("tock");

  motor.run(BACKWARD);
  for (i=0; i<255; i++) {
    motor.setSpeed(i);  
    delay(10);
 }
 
  for (i=255; i!=0; i--) {
    motor.setSpeed(i);  
    delay(10);
 }
  

  Serial.print("tech");
  motor.run(RELEASE);
  delay(1000);
}

I've merged your cross posts @sidharthsp66.

Cross posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes writing a detailed answer on this thread, without knowing that someone else already did the same in the other thread.

Repeated cross posting will result in a suspension from the forum.

In the future, please take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

then where can i control no of rotations

There are a number of ways ranging from a switch that is activated each time the motor shaft passes a particular spot, detecting a mark on the shaft by optical sensor, detecting a magnet fixed to the shaft, detecting a slot or slots in a wheel attached to the output shaft, using a rotary encoder attached to the shaft, using a servo motor to move the shaft a fixed number of degrees and using a stepper motor.

What you cannot do is to rotate the output for a fixed time and hope that it will always move a fixed angle.

then can i rotate motor forward for 10 sec and backward 10 seconds

sidharthsp66:
then can i rotate motor forward for 10 sec and backward 10 seconds

Does it actually matter how much the motor rotates in the given time ?

i am using arduino leonardo AFmotor.h isnt working on it

How is it wired, how are the motors powered and what code are you using ?

What does

isnt working

mean exactly ?

i made it in circuit.io
i have attached the file

Firmware.ino (9.59 KB)

You have not said what isn't working

Where are the motors and servos are powered from ?
The picture that you provided is practically useless