Professional Documents
Culture Documents
Driving DC Motors L293D
Driving DC Motors L293D
Now that we know everything about the shield, we can begin hooking it up
to our Arduino!
Next, connect power supply to the motors. Although you can connect DC
motors having voltages between 4.5 to 25V to the shield, in our experiment
we are using DC Motors that are rated for 9V. So, we will connect external
9V power supply to the EXT_PWR terminal.
Now, connect the motor to either M1, M2, M3 or M4 motor terminals. In our
experiment we are connecting it to M4.
CODE
#include <AFMotor.h>
AF_DCMotor motor(1);
void setup()
{
//Set initial speed of the motor & stop
motor.setSpeed(200);
motor.run(RELEASE);
}
void loop()
{
uint8_t i;
// Turn on motor
motor.run(FORWARD);