- Create an account in TINKERCAD
- Create a new Circuit
- Breadboard.
- Arduino Uno R3.
- DC Motors.
- Wires.
- L293D H Bridge.
- Battery
A motor driver is an integrated circuit chip which is usually used to control motors in autonomous robots. Motor driver act as an interface between Arduino and the motors . The most commonly used motor driver IC’s are from the L293 series such as L293D, L293NE, etc. These ICs are designed to control 2 DC motors simultaneously. L293D consist of two H-bridge. H-bridge is the simplest circuit for controlling a low current rated motor.L293D has 16 pins.
step2: Connect input1 with 13 pin, input2 with 12, input3 with 8 pin pin, input4 with 7 pin on Arduino.
NOTE: DC Motor will rotating in clockwise direction and if you want to run DC motor in anticlockwise direction we need to some change in the code (Replace HIGH to LOW and vice versa).
void loop()
{
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
}
But, if you want it to rotate in both directions with a while in between, then you need to set a delay for number of millisecond then the direction of rotation changes to other side.
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
}