hi i am using the l293d wired as following
+5v(pin1
input(pin2
motor(pin3
ground(pin4
ground(pin5
motor(pin6
input(pin7
+5v(pin8
and used this to check if its working
#define leftDir1 7 // Left motor direction 1, to AIn1
#define leftDir2 6 // Left motor direction 2, to AIn2
#define DELAY 10000 // (ms) milliseconds
void setup()
{
pinMode(leftDir1, OUTPUT); // Set motor direction pins as outputs.
pinMode(leftDir2, OUTPUT);
}
void loop()
{
digitalWrite(leftDir1, LOW); // Expect left motor to go forward
digitalWrite(leftDir2, HIGH); // (counterclockwise).
delay(DELAY);
digitalWrite(leftDir1, HIGH); // Expect left motor to go backward.
digitalWrite(leftDir2, LOW);
delay(DELAY);
digitalWrite(leftDir1, LOW); // Expect left motor to turn off.
digitalWrite(leftDir2, LOW);
delay(DELAY);
}
the motor spins in one direction but dosent spin in the other direction please help
#define leftDir1 7 // Left motor direction 1, to AIn1
#define leftDir2 6 // Left motor direction 2, to AIn2
#define DELAY 10000 // (ms) milliseconds
void setup()
{
pinMode(leftDir1, OUTPUT); // Set motor direction pins as outputs.
pinMode(leftDir2, OUTPUT);
}
void loop()
{
digitalWrite(leftDir1, LOW); // Expect left motor to go forward
digitalWrite(leftDir2, HIGH); // (counterclockwise).
delay(DELAY);
digitalWrite(leftDir1, LOW); // Expect left motor to turn off.
digitalWrite(leftDir2, LOW);
delay(DELAY);
digitalWrite(leftDir1, HIGH); // Expect left motor to go backward.
digitalWrite(leftDir2, LOW);
delay(DELAY);
digitalWrite(leftDir1, LOW); // Expect left motor to turn off.
digitalWrite(leftDir2, LOW);
delay(DELAY);
}
If you want me to assist on this, please post a clear and accurate schematic showing the connections from the Arduino to the L293, and affirm that the code you are using is the same as the last posted code posted by AlphaBeta.
the 5v and groun are connected to arduino
the input pins ara 6,7 on arduino
i'm using a 45rpm geared dc motor
"the motor is rotating only in one direction" even if i give the command to reverse it first
i tried wiring up both the sides then also it rotates only in one direction and the other side also has the same wiring except for inputs they differ so ididn;t mentoin
please help me out!
give me a link if possible on how to trouble shoot l293d
THANKS richard,alfabeta and crosh you people helped me out after much trouble shooting i learnt many things about the L293d and now built a new one this works fine
i have a doubt on programming
for example can we create a program for a common thing that repeats itself name it and use only the name instead of writing the entire program if it is possible please give me an example
for example can we create a program for a common thing that repeats itself name it and use only the name instead of writing the entire program
This sounds like you want to create a function, like loop() or setup() or Serial.begin(), and call it (like loop() or setup() or Serial.begin()).
Yes, it is possible.
functionReturnType functionName(functionArgumentType functionArgument)
{
// The function does something
functionReturnType retrunValue = SomeValue;
return returnValue;
}
void loop()
{
functionName(someValue); // Call the function
}