Nano 33 IoT to L298N

Trying to control 4 motors, 2 left, 2 right with L298N connected to Arduino nano 33 iot.

L298 works as expected, when taking loose wire from 5V and touching the IN pins I get expected behavior

However, motors do not spin when IN pins are connected to arduino D2-5. Arduino is connected via USB, and grounded to L298

ChatGPT suggests 3.3 V is too little to send High signal but I am skeptical

Arduino code works as expected, uploads, prints the correct things after the correct delays, just don’t spin the motors. If the H bridge and Arduino work by themselves then I must have wired them wrong?

Any ideas?

One idea is to provide the information needed to get help, like a complete schematic wiring diagram and links to the components.

Please read and follow the instructions in the "How to get the best out of this forum" post, linked at the head of very forum category.

5V: This pin outputs 5V from the board when powered from the USB connector. Note: for it to work, you need to short the VBUS jumper on the back of the board. If you power the board from the VIN pin, you won’t get any regulated 5V and even if you do the solder bridge.

I appreciate the crudeness of this but I have no other tools. Here is one half of what I have going on. Connecting the 5V terminal on the L298 to any of the IN pins works, but not with the Arduino in the way

And the code, which does print when prompted in coolterm

// L298N Motor Driver Pins
#define ENA 9   // Left side motor speed (PWM)
#define IN1 2   // Left side reverse
#define IN2 3   // Left side forward

#define ENB 10  // Right side motor speed (PWM)
#define IN3 4   // Right side reverse
#define IN4 5   // Right side forward

int speedVal = 150; 

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  Serial.begin(9600);
  while (!Serial);   
  delay(2000);       

  Serial.println("Ready: use w/a/s/d/x and </> to control");
}

void loop() {
  if (Serial.available()) {
    char command = Serial.read();

    switch (command) {
      case 'w': // Forward
        forward();
        Serial.println("Forward");
        break;
      case 's': // Reverse
        backward();
        Serial.println("Reverse");
        break;
      case 'a': // Left turn
        turnLeft();
        Serial.println("Left");
        break;
      case 'd': // Right turn
        turnRight();
        Serial.println("Right");
        break;
      case 'x': // Stop
        stopMotors();
        Serial.println("Stop");
        break;
      case '.': // Increase speed
        speedVal = min(speedVal + 25, 255);
        Serial.print("Speed: "); Serial.println(speedVal);
        break;
      case ',': // Decrease speed
        speedVal = max(speedVal - 25, 0);
        Serial.print("Speed: "); Serial.println(speedVal);
        break;
      default:
        Serial.println("Invalid command");
    }
  }
}

void forward() {
  digitalWrite(IN1, LOW);   // Left reverse off
  digitalWrite(IN2, HIGH);  // Left forward on
  digitalWrite(IN3, LOW);   // Right reverse off
  digitalWrite(IN4, HIGH);  // Right forward on
  analogWrite(ENA, speedVal);
  analogWrite(ENB, speedVal);
}

void backward() {
  digitalWrite(IN1, HIGH);  // Left reverse on
  digitalWrite(IN2, LOW);   // Left forward off
  digitalWrite(IN3, HIGH);  // Right reverse on
  digitalWrite(IN4, LOW);   // Right forward off
  analogWrite(ENA, speedVal);
  analogWrite(ENB, speedVal);
}

void turnLeft() {
  digitalWrite(IN1, HIGH);  // Left reverse
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);   // Right forward
  digitalWrite(IN4, HIGH);
  analogWrite(ENA, speedVal);
  analogWrite(ENB, speedVal);
}

void turnRight() {
  digitalWrite(IN1, LOW);   // Left forward
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);  // Right reverse
  digitalWrite(IN4, LOW);
  analogWrite(ENA, speedVal);
  analogWrite(ENB, speedVal);
}

void stopMotors() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
}

Would this mean connecting 5V on the Arduino to 5V on the L298 even with it plugged into laptop USB? The only thing connected to L298 right now besides the jumper wires are GRD

Please explain the meaning of this comment, and post links to the components.

The L298 logic circuitry must be powered by 5V, which is not shown in the wiring diagram.
By the way, pencil and paper works very well for wiring diagrams.

Ah…. I think that’s the issue. no 5V supply going IN to L298?

What I mean is that it works when I manually touch IN pins with 5V on the board here

The L298 module has facility for its own 5V (derived from its VIN, “12V”).

I can only get motors spinning when I take that 5V from L298 and provide it to the INs on the L298 itself. if I try to have the Arduino send 5 (or 3.3V) to any of these pins, I don’t get any spinning

No it would not. Just wondering which 5V you were using for testing, the one from the nano or the one from the L298

Is it one that looks like this

that’s the one!

The nano has a 3.3V output pin. Try using that for testing the IN1 and IN2 pins.

  • This PDF should give you a better understanding of the motor driver.
  • The red 5v wire to the Arduino is not used when the Arduino has its own power.
    The driver board has its own 5v power supply, the 5v enable jump would be installed.
    The driver would be powered from you battery pack.

I tried 3.3V out and it didn’t spin, I also tried the 5V output Arduino pin and nothing again,

The 5V output pin on the Nano 33 IoT is disabled by default. See post #3.

That is not good. It means your L298 will not work with 3.3V.

Just to be sure, disconnect ENA , IN1 and IN2 from the nano, keep the GND connected.
Put the jumper back on the ENA, connect IN1 to 3.3V, connect IN2 to GND.
If still no spinning something wrong with L298.

Nothing with this set up either. so this board is incompatible with the 33 nano?

They usually work just fine with 3.3V signals. Can you measure your Nano pin voltage?

No. I have not come across anyone who has had a problem with a 3.3V processor. Do you have a DMM/ voltmeter or something to measure the 3.3V output?