Introduction: How to Use a L293D Chip With Arduino and a Motor

Picture of How to Use a L293D Chip With Arduino and a Motor

Lets control an DC Motor with a L293D Chip and Make it so it will go clockwise or counter clockwise.

I received a kit from GearBest that included all the parts I needed for this project and recommend it to you if you are just starting with Arduino, You can check it out here!


The parts you will need are:

1) Arduino Board with PWM

2) L293D Motor Driver

3) Wires

4) External Power Supply (not needed but recommended)

5) 10 minutes

Lets Begin!

Step 1: Wire Everything!

Picture of Wire Everything!

Now were going to wire everything.

I created the schematic to make it easier to understand, then used that for reference when wiring it. Its super simple!

For people that cant see the picture notes:

In the schematic the bottom wire from the chip is the one you would connect to the power supply positive, i didn't add it to keep things simple.

Step 2: Code the Arduino

Picture of Code the Arduino

The code is super simple, we use "for" statements and "analogWrite" to control it.

For Example:

when pin 5 is low and pin 6 is high it will rotate clockwise

or

when pin 5 is high and pin 6 is low it will rotate counter-clockwise

You can download the code from here

Here is the code also:


void setup() {

  }

void loop() {
  for(int i = 0; i<255; i++){
    analogWrite(5, i);
    analogWrite(6, 0);
    delay(5);
  }
  for(int i = 0; i<255; i++){
    analogWrite(5, 255-i);
    analogWrite(6, 0);
    delay(5);
  }
  for(int i = 0; i<255; i++){
    analogWrite(5, 0);
    analogWrite(6, i);
    delay(5);
  }
  for(int i = 0; i<255; i++){
    analogWrite(5, 0);
    analogWrite(6, 255-i);
    delay(5);
  }
}

Step 3: Test It Out!

Picture of Test It Out!

Your motor should now get increasingly faster then decelerate reverse direction and repeat!

If you have any questions leave them in the comments and i will try to help you out.

Hope you enjoyed

Comments

hkrewinkel (author)2016-10-01

that speaker stabilizing solution is great!!

Funguypro (author)hkrewinkel2016-10-01

thanks, I actually accidentally had the motor attach to the speaker and thought "hey this is really useful". now I use it a lot

hkrewinkel (author)2016-10-01

the rest if your instructable too :)

About This Instructable

2,159views

37favorites

License:

Bio: I like to create new things! I'm very interested in IOT and just Internet Stuff. I am not responsible for any injury or deaths ... More »
More by Funguypro:3D Print Your House!!!!!DIY Raspberry Pi Indoor Outdoor WebcamSee Through Buildings With a Drone
Add instructable to: