How to control speed of DC motor with L293D IC and arduino?

I am new to arduino and I am working on a project i which I have been able to control LEDs with arduino and android via bluetooth module. I want to control the speed of DC motor with arduino and L293D IC like this guy did:

I am comfortable with android programming but less with arduino as it involves electronics concepts.
Please help, how can I do the project similar to the guy's in the video?

Thanks

Controlling speed and direction of a DC motor using an Android App. by Tenet
The BlueSMiRF is the latest Bluetooth wireless serial cable .These modems work as a serial (RX/TX) pipe. Any serial stream from 2400 to 115200bps can be passed seamlessly from your computer to your target.

I am new to arduino and I am working on a project i which I have been able to control LEDs with arduino and android via bluetooth module. I want to control the speed of DC motor with arduino and L293D IC like this guy did:] I am new to arduino and I am working on a project i which I have been able to control LEDs with arduino and android via bluetooth module. I want to control the speed of DC motor with arduino and L293D IC like this guy did:

Ok, help me out here. I understand what you said , but why are you posting ?
Is there a question ?
Maybe I should clarify,
Did you buy this ?

Did you read the datasheet ?
Did you look at the schematic ?
Did you read the Hookup Guide ?
Did you read the RN-41 AT Command Set ?
Did you read the Bluetooth Primer ?
Did you download and install the library ?
Have you used the L293 before ?
Did you research on Google ?
Did you read the tutorials ?
Do you have a motor ?
Which one ?
Do you have an L293 IC?
Have you used it yet ?
Is there a question ?

raschemmel:
Is there a question ?

Yes there is.

I have tried google search, I have read tutorials on internet and they all use other components and those using L293 IC are not having circuit diagrams. I just need some advice that's why I posted here. If you know any good tutorial then please tell me but If you don't want to help then please stay out of the topic. I have to do this today, it is urgent.

This has the wiring diagram and the code.
http://garagelab.com/profiles/blogs/tutorial-l293d-h-bridge-dc-motor-controller-with-arduino
What do you know , so does this one:
http://letsmakerobots.com/node/2074
And this one even has bluetooth:

so does this one.

http://tune.pk/video/2365418/Arduino-Control-2-DC-Motors-Via-Bluetooth-Tutorial

I have to do this today, it is urgent.

http://www.electroschematics.com/9623/vk-2wd-electric-car/

Maybe you should leave your homework until the last minute.

raschemmel:
This has the wiring diagram and the code.
http://garagelab.com/profiles/blogs/tutorial-l293d-h-bridge-dc-motor-controller-with-arduino
What do you know , so does this one:
http://letsmakerobots.com/node/2074
And this one even has bluetooth:
Arduino – Control DC Motor via Bluetooth | Random Nerd Tutorials
so does this one.
http://www.instructables.com/id/Arduino-Control-DC-Motor-via-Bluetooth/step3/Arduino-Code/

Arduino - Control 2 DC Motors Via Bluetooth | Random Nerd Tutorials
http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/?ALLSTEPS

I have to do this today, it is urgent.

Maybe you should leave your homework until the last minute.

I saw all the tutorials and they all contain how to move the motor forward and backward but no speed control. I just need to know how can I increase or decrease the speed. Can it be done by changing values instead of HIGH/LOW in the digitalWrite(PIN, HIGH/LOW) . For example digitalWrite(11,100) etc..

It looks to me like this one shows how to set the speed

. Arduino Playground - DirectionalMotorControlWithAL293D

// This code creates a PWM signal that rotates a motor either left or right.
// PWN is used to reduce the voltage of the motor from 12V --> 5V
// This allows the power regulation for the digital part to be very small (and simple)
//
// Simple schematic:
//
//                  +-------+                         VCC2=12V
//                  | L293D |                         VCC1=5V
//                  | |\    |
// MOTOR_DIR -------+-| >---+------[(M)]-----+
//                  | |/    |                |
//                  |       |                |
//                  | |\    |                |
// MOTOR_PWM -------+-| >---+----------------+
//                  | |/    |
//                  |       |
//                  +-------+
 
#include <avr/interrupt.h>
#include <avr/io.h>  
 
// Make pulse width as such that average voltage=5V
// Value 110 is experimantal.....
// For testing purposes the value can be divided by two (2)
#define MOTOR_SPEED 110/2
 
int LEDPIN = 13;          // Heartbeat led
int MOTOR_DIR = 12;       // Non PWM pin for direction control
int MOTOR_PWM = 11;       // PWM controlled pin.
 
int int_counter = 0;  
 
// We have ~32000 Overflows per second...  
// Make led pulse to show its alive (heartbeat?)
ISR(TIMER2_OVF_vect) {  
  int_counter += 1;  
  if (int_counter == 3200) {  
    digitalWrite(LEDPIN, LOW);  
  }
  if (int_counter == 32000) {  
    int_counter = 0;
    digitalWrite(LEDPIN, HIGH);  
  }  
};  
 
// Turn the motor left.
// If the motor needs to turn right after this call,
// use motor_stop first!
void motor_left() {
  // Set the pulse width
  OCR2A=MOTOR_SPEED;
  // Set the directional bit to the correct value
  digitalWrite(MOTOR_DIR, HIGH);
  // Set output to PWM
  TCCR2A |= ((1<<COM2A1) | (1<<COM2A0));
}
 
// Turn the motor right.
// If the motor needs to turn left after this call,
// use motor_stop first!
void motor_right() {
  // Set the pulse width
  OCR2A=MOTOR_SPEED;
  // Set the directional bit to the correct value
  digitalWrite(MOTOR_DIR, LOW);
  // Set output to PWM (inverted of motor_left function)
  TCCR2A |= ((1<<COM2A1) | (0<<COM2A0));
}
 
// The following three commands should happen in the shortest time possible.
// TODO: So optimisation is needed!
void motor_stop() {
  // Disconnect the PWM
  TCCR2A &= ~((1<<COM2A1) | (1<<COM2A0));
  // And put is all back to a safe 'LOW'
  digitalWrite(MOTOR_DIR, LOW);
  digitalWrite(MOTOR_PWM, LOW);  
}
 
void setup() {  
  Serial.begin(9600);
  CLKPR=0;
 
  // Set the pins to output.
  pinMode(LEDPIN, OUTPUT);
  pinMode(MOTOR_DIR, OUTPUT);
  pinMode(MOTOR_PWM, OUTPUT);
  // And set these to a initial value to make sure.
  digitalWrite(MOTOR_DIR, LOW);
  digitalWrite(MOTOR_PWM, LOW);
 
 
  // Use phase correct PWM Mode and set Output Compare mode
  // Eventual PWM fequency will be ~30kHz, this is done to
  // - minimize noise
  // - minimize heat (suturation of motor --> L293=RIP)
  TCCR2A = (0<<WGM21) | (1<<WGM20) | (0<<COM2A1) | (0<<COM2A0) | (0<<COM2B1) | (0<<COM2B0);
  TCCR2B = (0<<WGM22) | (0<<CS22) | (0<<CS21) | (1<<CS20) | (0<<FOC2A) | (0<<FOC2B);
  //Timer2 Overflow Interrupt Enable for the heartbeat
  TIMSK2 |= (1<<TOIE2) | (0<<OCIE2A);
  //sei();  // Not needed at this moment.
}  
 
void loop() {  
  motor_left();
  delay(1000);
  motor_stop();
 
  motor_right();
  delay(1000);
  motor_stop();
}

L293.ino (3.28 KB)

l293d.pdf (372 KB)

For example digitalWrite(11,100)

No, that is exactly the same as For example digitalWrite(11,HIGH)
You need to look at analogWrite.

AWOL:

For example digitalWrite(11,100)

No, that is exactly the same as For example digitalWrite(11,HIGH)
You need to look at analogWrite.

Thanks for the reply.
Just one silly question: Can I vary the value between 0 to 255 to change the speed or are they fixed?
Like analogWrite(PIN,50) for some speed and analogWrite(PIN,150) for thrice that speed?

raschemmel:
It looks to me like this one shows how to set the speed

. Arduino Playground - HomePage

Thanks

Just one silly question: Can I vary the value between 0 to 255 to change the speed or are they fixed?
Like analogWrite(PIN,50) for some speed and analogWrite(PIN,150) for thrice that speed?

You tell me.

raschemmel:

Just one silly question: Can I vary the value between 0 to 255 to change the speed or are they fixed?
Like analogWrite(PIN,50) for some speed and analogWrite(PIN,150) for thrice that speed?

You tell me.
http://arduino.cc/en/Reference/AnalogWrite

Well I got it now. I was just confused between that article and another article on internet.

Thanks again for your cheerful advice :slight_smile:

Sorry if I'm not thrilled that you waited till the last minute to do your homework and then came here to ask for urgent help.
If you want cheerful don't sound so frantic. We're here to help people learn, not to do their homework.