user57419: I am currently using the arduino Uno connected with L298N(green pcb) connected to a dc motor rated 12V. I provided dedicated 12v power supply to the dc motor and the arduino board's power is supplied by usb connected to my pc. I connected Pin 9 of arduino uno to 'ENA' on L298N , Pin 7 & 8 (UNO) to 'INA' & 'INB' of L298N. Connected '-' polarity of Motor power supply to GND of L298N, while also connecting the 'GND' of L298N to the GND of Arduino UNO. Last but not least, connecting the 'OUT B'to the dc motor. This is the picture of how L298N(green) look like https://sea.banggood.com/Green-Board-L298N-DC-Motor-Driver-Board-Stepper-Motor-p-974549.html?cur_warehouse=CN 
Can i check why my motor isn't running? Thanks in advance.
char data = 0;
int enB = 9;
int InC = 8;
int InD = 7;


void setup()
{
    Serial.begin(9600);                   
    Serial.println("Motor test !");
  pinMode(enB, OUTPUT);
   pinMode(InC, OUTPUT);
  pinMode(InD, OUTPUT);

}


void loop()
{Serial.println("Entered loop, should start moving now !");
  digitalWrite(InC, HIGH);
  digitalWrite(InD, LOW);
   digitalWrite(enB, HIGH);
   analogWrite(enB, 255);
 }


user57952: Well, your wiring is OK, but I think the
'digitalWrite(enB, HIGH);
in the loop() code is causing your problem.  You don't want to try to use the same pin for both digital and analog functions.
I wired up a Uno here with your setup and a L298N, and got a motor to run fine with the following sketch that doesn't use the loop() at all - it does everything in setup().
char data = 0;
int enB = 9;
int InC = 8;
int InD = 7;


void setup()
{
    Serial.begin(9600);
    Serial.println("Motor test !");
    pinMode(enB, OUTPUT);
    pinMode(InC, OUTPUT);
    pinMode(InD, OUTPUT);

    Serial.println("motor should start moving now !");
    digitalWrite(InC, HIGH);
    digitalWrite(InD, LOW);
    //digitalWrite(enB, HIGH);

    for (size_t i = 0; i < 10; i++)
    {
        analogWrite(enB, 20*i);
        Serial.print("motor speed = "); Serial.println(20 * i);
        delay(2000);
    }

    Serial.println("quitting!");
    while (true)
    {

    }

}


void loop()
{
    //Serial.println("Entered loop, should start moving now !");
    //digitalWrite(InC, HIGH);
    //digitalWrite(InD, LOW);
    //digitalWrite(enB, HIGH);
    //analogWrite(enB, 255);
}

If you can't get your motor working with the above program, then you most likely have a connection or power supply or component problem that you'll need to troubleshoot.
Hope this helps,
Frank

57419: <p>I am currently using the arduino Uno connected with L298N(green pcb) connected to a dc motor rated 12V. I provided dedicated 12v power supply to the dc motor and the arduino board's power is supplied by usb connected to my pc. I connected Pin 9 of arduino uno to 'ENA' on L298N , Pin 7 &amp; 8 (UNO) to 'INA' &amp; 'INB' of L298N. Connected '-' polarity of Motor power supply to GND of L298N, while also connecting the 'GND' of L298N to the GND of Arduino UNO. Last but not least, connecting the 'OUT B'to the dc motor. This is the picture of how L298N(green) look like <a href="https://sea.banggood.com/Green-Board-L298N-DC-Motor-Driver-Board-Stepper-Motor-p-974549.html?cur_warehouse=CN" rel="nofollow noreferrer">https://sea.banggood.com/Green-Board-L298N-DC-Motor-Driver-Board-Stepper-Motor-p-974549.html?cur_warehouse=CN</a> </p>

<p>Can i check why my motor isn't running? Thanks in advance.</p>

<pre><code>char data = 0;
int enB = 9;
int InC = 8;
int InD = 7;


void setup()
{
    Serial.begin(9600);                   
    Serial.println("Motor test !");
  pinMode(enB, OUTPUT);
   pinMode(InC, OUTPUT);
  pinMode(InD, OUTPUT);

}


void loop()
{Serial.println("Entered loop, should start moving now !");
  digitalWrite(InC, HIGH);
  digitalWrite(InD, LOW);
   digitalWrite(enB, HIGH);
   analogWrite(enB, 255);
 }
</code></pre>
 57952: <p>Well, your wiring is OK, but I think the</p>

<p>'digitalWrite(enB, HIGH);</p>

<p>in the loop() code is causing your problem.  You don't want to try to use the same pin for both digital and analog functions.</p>

<p>I wired up a Uno here with your setup and a L298N, and got a motor to run fine with the following sketch that doesn't use the loop() at all - it does everything in setup().</p>

<pre><code>char data = 0;
int enB = 9;
int InC = 8;
int InD = 7;


void setup()
{
    Serial.begin(9600);
    Serial.println("Motor test !");
    pinMode(enB, OUTPUT);
    pinMode(InC, OUTPUT);
    pinMode(InD, OUTPUT);

    Serial.println("motor should start moving now !");
    digitalWrite(InC, HIGH);
    digitalWrite(InD, LOW);
    //digitalWrite(enB, HIGH);

    for (size_t i = 0; i &lt; 10; i++)
    {
        analogWrite(enB, 20*i);
        Serial.print("motor speed = "); Serial.println(20 * i);
        delay(2000);
    }

    Serial.println("quitting!");
    while (true)
    {

    }

}


void loop()
{
    //Serial.println("Entered loop, should start moving now !");
    //digitalWrite(InC, HIGH);
    //digitalWrite(InD, LOW);
    //digitalWrite(enB, HIGH);
    //analogWrite(enB, 255);
}
</code></pre>

<p>If you can't get your motor working with the above program, then you most likely have a connection or power supply or component problem that you'll need to troubleshoot.</p>

<p>Hope this helps,</p>

<p>Frank</p>
