Arnov Sharma
Published © MIT

Motor Driver Patch

Motor Driver Patch is a DIY H-bridge-based dual motor driver featuring 8 N-channel MOSFET ICs connected in an H-bridge configuration.

BeginnerFull instructions provided1 hour124
Motor Driver Patch

Things used in this project

Hardware components

JLCPCB Customized PCB
JLCPCB Customized PCB
×1
XIAO ESP32C3
Seeed Studio XIAO ESP32C3
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

SCH

Code

code

C/C++
const int IN_A = 5;  // Base of NPN #1
const int IN_B = 6;  // Base of NPN #2

void setup() {
  Serial.begin(115200);
  delay(500);

  pinMode(IN_A, OUTPUT);
  pinMode(IN_B, OUTPUT);

  // Safe-ish initial state: both HIGH (through NPN this usually means both LOW at H-bridge)
  digitalWrite(IN_A, HIGH);
  digitalWrite(IN_B, HIGH);

  Serial.println("=== H-Bridge 4-state test on pins 7 & 8 ===");
}

void setState(int a, int b, const char* label) {
  Serial.print(label);
  Serial.print("  -> IN_A = ");
  Serial.print(a == HIGH ? "HIGH" : "LOW");
  Serial.print("  IN_B = ");
  Serial.println(b == HIGH ? "HIGH" : "LOW");

  digitalWrite(IN_A, a);
  digitalWrite(IN_B, b);
}

void loop() {
  // State 1: A = LOW, B = LOW
  setState(LOW, LOW,  "State 1");
  delay(3000);

  // State 2: A = LOW, B = HIGH
  setState(LOW, HIGH, "State 2");
  delay(3000);

  // State 3: A = HIGH, B = LOW
  setState(HIGH, LOW, "State 3");
  delay(3000);

  // State 4: A = HIGH, B = HIGH
  setState(HIGH, HIGH, "State 4");
  delay(3000);
}

Credits

Arnov Sharma
361 projects • 369 followers
I'm Arnov. I build, design, and experiment with tech—3D printing, PCB design, and retro consoles are my jam.

Comments