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:
- Arduino UNO
- DRV8871 (from aliexpress) -> https://www.aliexpress.com/item/1005007706435353.html -
- Lego Power Function S -> LEGO Medium Power Functions Motor (16512 / 58120) | Brick Owl - LEGO Marché
- Lego Power Function Battery Box 9v -> Boîtier à piles LEGO® Power Functions 8881 | Autre | Boutique LEGO® officielle CH
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 :



