Sub topic 9
Powering the Motor and Logic: Shared Ground and Decoupling
Assume you know pinMode, digitalWrite, and analogWrite, and that you can read a simple wiring diagram. This chapter focuses on supplying power safely to an Arduino and an H-bridge driver.
Use separate power paths
The motor draws much more current than the Arduino. A motor can also create fast voltage changes when it starts, stops, or changes direction. For this reason, power the motor from a supply that matches the motor and driver ratings. Do not normally power the motor from the Arduino’s 5 V pin.
The Arduino supplies logic signals. The driver supplies motor current.
| Connection | Purpose |
|---|---|
| Motor supply positive to driver VM or VIN | Supplies motor power |
| Arduino 5 V or 3.3 V to driver logic supply | Powers the driver’s control circuit, when required |
| Arduino GND to driver GND | Gives signals a shared voltage reference |
| Motor wires to driver output terminals | Carries the switched motor current |
The motor supply voltage must stay within the driver’s allowed range. Its current rating should handle the motor’s running current and the temporary surge near startup or stall.
Connect the grounds
A shared ground is required even when the Arduino and motor use separate supplies. An Arduino output marked HIGH has meaning only relative to the driver’s ground. Without a common reference, the driver may see an undefined input voltage or may not respond at all.
Connect the Arduino ground and the driver logic ground. Connect the motor supply negative to the driver’s motor-ground terminal. Many modules combine these grounds internally, but check the module documentation before assuming that they are connected.
Keep high motor-current paths separate from sensitive logic paths where possible. A useful arrangement is to bring the motor supply negative and the logic supply negative to the driver, then connect the Arduino ground near the driver ground. Avoid routing motor current through a thin breadboard trace shared with the Arduino.
Add decoupling capacitors
A decoupling capacitor supplies short bursts of current and absorbs some voltage noise. Place capacitors physically close to the driver’s power pins, with short wires.
Use two types:
- A ceramic capacitor, often 100 nF, handles fast switching noise.
- A bulk capacitor, such as 47 µF to 470 µF, handles slower current changes and motor startup pulses.
The exact values depend on the driver, motor, wiring length, and supply. Follow the driver data sheet when it specifies values. Observe polarity on electrolytic bulk capacitors. The positive lead goes to the positive supply, and the negative lead goes to ground.
Some drivers also need a separate capacitor on the logic supply. Add it close to the logic power and ground pins rather than several centimeters away on a breadboard.
const uint8_t IN1 = 7;
const uint8_t IN2 = 8;
const uint8_t ENABLE = 9;
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENABLE, OUTPUT);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
analogWrite(ENABLE, 0); // Keep the motor off at startup.
}
void loop() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
analogWrite(ENABLE, 160);
delay(2000);
analogWrite(ENABLE, 0);
delay(500);
}Check the wiring under load
A motor may work without a load but reset the Arduino when it starts. This usually indicates supply droop, poor grounding, electrical noise, or insufficient bulk capacitance. Measure the driver’s motor voltage while the motor starts. If it falls sharply, use shorter, thicker power wires, a stronger supply, or a larger suitable capacitor.
If the Arduino resets while the motor runs, power it from a separate regulated supply or USB source, keep the grounds connected, and improve the ground layout. Do not assume that a higher-rated supply fixes every problem. The driver and motor must still tolerate the applied voltage and current.
Exercise
Why must the Arduino ground connect to the driver ground when the motor has a separate battery?
Show answer
The shared ground gives the Arduino control signals and the driver the same voltage reference, allowing the driver to interpret HIGH and LOW correctly.