wiring and code chek please

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 :cry:

i'm using a 45 rpm geared dc motor

does the motor stop?

does the motor go backward if you tell it to first?

yes the motor stops i'll check out if it reverses wen i tell it first to reverse

checked out whatever iz the command it rotates only in one direction

how about this:

#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);
}

?

ill reply after check ing out

i checked out your code also pls check the wiring ! :cry:

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.

:slight_smile:

i found out taht the code iscorrect
the problem is that the motor rotates only in one direction
i dont know how to insert a image here :-?

+5v ----- ------
input------- ------
motor------- ------
gnd---------- l293d ------
gnd---------- ------
motor---------- ------
input---------- ------
+5v----------- ------

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

the pin setup is same on both the sides

  1. 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 :slight_smile: :slight_smile:

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 :slight_smile:

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
}