Help with motor driver DRV8871 to control lego Motor

Hi everyone,

I'm a beginner in electronics. For a project I want to control Lego Power Functions motors with an Arduino.

Here is my setup:

I connected the Arduino to the Lego 9V battery box, the DRV8871, and the Lego motor. (see pictures)

The problem:
The motor does not spin.

  • The Arduino is powered correctly by the battery box.
  • I checked that the Lego motor works when connected directly to the battery.

I have a few doubts:

  • On my first attempt, I accidentally inverted the battery polarity (+ and –) for a few seconds. Could that have damaged the DRV8871?
  • When I measure the voltage between Arduino 5V and Arduino GND with my multimeter, I get 9V. ChatGPT told me this might be normal because of how the DRV8871 board is wired, but I’m not sure.
  • I looked for a short circuit but I couldn’t find any.

Does anyone see where my mistake is ? Could it be my wiring, my code, or maybe the DRV8871 module itself ?

Thanks in advance for your help!

My code:

int IN1 = 4;
int IN2 = 5;

void setup() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
}

void loop() {
//Turn Forward
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  delay(2000);
 //Turn Reverse
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  delay(2000);
}

My Circuit :


What are the technical specifications for that battery? What's inside it?

What's the third motor pin?
Where is a motor data sheet (English?)

Inside the battery there are 6 x 1.5V AA.
I don't know the specification of the battery when I googled : "lego battery box 58119 " i didn't find anythings

The motor has 4pin but only 2 are used.

I only found this for the datasheet from this website : LEGO 9V Technic Motors compared characteristics

I believe the 9V nad C1 pins are internally connected and the 0V and C2 are internally connected so that a plug and cable arrangement can daisy chain motors together.

Need to check with a DMM.

Tom.... :smiley: :+1: :coffee: :australia:

6x AA has a chanse to work. No further specs needed.

Adding decoupling caps and a kick back diode would sure make the noise level lower making the controller power cleaner.

Yes.

If accurate, that's bad, unacceptable.