Turn the knob, the motor changes speed. PWM switches power on and off faster than the motor can respond, so average voltage falls and so does speed. You also learn why a motor never connects to a GPIO pin: it draws far too much current and dumps voltage spikes back down the line when it stops. The L9110 module handles both problems for you.
Every item is in the kit — nothing extra to buy.
All 24 parts in one box, with this project and 15 more to build from them.
One of each part. Packs (resistor assortment, jumper wires) already hold more than a single build needs. Backorder parts ship once they arrive — the kit above has every part boxed today. Delivery is free on orders AED 150.00+.
Written for the board in the kit. Copy it into the Arduino IDE; change the pin numbers if you wire it differently.
/*
10 — Motor speed control
Board: ESP32. Parts: potentiometer, DC motor, L9110 module.
Wiring:
Potentiometer: outer legs -> 3V3 and GND, wiper -> GPIO 35
L9110 module: VCC -> VIN (5 V), GND -> GND, A-1A -> GPIO 16, A-1B -> GPIO 17
Motor -> the module's MOTOR A screw terminals
(never a motor straight on a GPIO: far too much current, and
a voltage spike back down the line when it stops)
Turn the knob, the motor changes speed. PWM switches the power on and off
faster than the motor can respond, so the average voltage — and the speed —
follows the duty cycle. Below ~30 % most small motors just hum: MIN_DUTY skips that.
*/
const int POT_PIN = 35;
const int A1A_PIN = 16; // PWM = speed
const int A1B_PIN = 17; // LOW = forward (swap the two for reverse)
const int MIN_DUTY = 70; // 0..255; below this the motor stalls and hums
void setup() {
Serial.begin(115200);
pinMode(A1A_PIN, OUTPUT);
pinMode(A1B_PIN, OUTPUT);
digitalWrite(A1B_PIN, LOW);
}
void loop() {
int raw = analogRead(POT_PIN); // 0..4095
int duty = map(raw, 0, 4095, 0, 255);
if (duty < 8) duty = 0; // knob at the bottom = fully off
else if (duty < MIN_DUTY) duty = MIN_DUTY;
analogWrite(A1A_PIN, duty); // ESP32 core 2.0.2+ supports analogWrite
Serial.print("knob "); Serial.print(raw); Serial.print(" duty "); Serial.println(duty);
delay(50);
}
The SG90 holds a commanded angle rather than just spinning, which is what makes it useful for gates, dispensers and valves. You drive it with a PWM pulse whose width set…
Run the same motor through both drivers and learn why there is more than one. The L9110 takes two pins per motor and you PWM one of them. The L293D separates the jobs: d…
Mount the ultrasonic sensor on the servo, sweep it through its range, and record distance at each angle. You now have a set of angle-and-distance pairs — a crude map of…