Labs / Motors · Intermediate · 40 min
DC motor speed
See how speed falls with load and current rises.
Engineering instrumentation: This lab includes an instrument-style virtual test setup and parameter-driven waveform. For physical measurements, use the Practical Bench.
Parts
- DC motor
- L298N or L9110 driver
- ESP32
- 12 V supply
- Flyback diodes
Steps
- Connect the driver inputs to the ESP32.
- Power the motor from a separate supply, join the grounds.
- Apply PWM on ENA.
- Add load and note the speed change.
Safety: check polarity and power off before changing the circuit.
ESP32 code (Arduino IDE)
const int IN1=26, IN2=27, ENA=25;
void setup(){ pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); ledcAttach(ENA,20000,8); }
void loop(){ digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); ledcWrite(ENA,120); }Viva questions
Why a separate motor supply?
Motors draw large and noisy currents that can reset the ESP32.
Why do load and current rise together?
More torque needs more current in the windings.
How to reverse direction?
Swap the polarity using the driver IN1 and IN2.