Français

Lessons · Lesson A3 · Actuators and motors · 35 min

DC motors and H-bridges

Understand what an H-bridge does, then make a small DC motor go forward, backward, brake or coast, at the speed you choose, with a DRV8833 board and its own power supply. About 35 minutes, with switches you can click.

Reversing a motor

A small DC motor has two wires. Connect it to a battery and it spins one way. Swap the two wires and it spins the other way [4].

So to make a robot go backward, you need to swap those wires, many times a second if you like, without touching them. That is the job of an H-bridge: a circuit that connects the motor to the supply in one direction or the other, on command. It is the same idea as swapping the wires, done with switches [4].

In this lesson you will:

  1. see how four switches can reverse a motor,
  2. meet the DRV8833 board, which holds two H-bridges,
  3. make a motor go forward, backward, brake or coast, and choose its speed.
Swap the two wires, the motor turns the other way A small DC motor with a battery, drawn twice side by side. a: the red wire goes from the battery's plus to the motor's tab A, the black wire from minus to tab B; the arrow on the wheel turns clockwise. b: the wires are swapped, red from plus to tab B, black from minus to tab A; the arrow turns anticlockwise. An H-bridge does this swap with switches, on command. FIG. 1 — ONE MOTOR, TWO DIRECTIONSaRed to A+batteryMABred: + → Ablack: − → BclockwisebWires swapped+batteryMABred: + → Bblack: − → AanticlockwiseAn H-bridge does this swap with switches, on command.
Tap the diagram to open it full screen.

The H-bridge: four switches

Draw the motor in the middle. Put one switch between each motor wire and the + of the supply, and one switch between each motor wire and the −. That is four switches, and the drawing looks like the letter H, with the motor as the crossbar.

  • Close the top-left and the bottom-right switches: current goes through the motor from left to right.
  • Close the top-right and the bottom-left switches: current goes through the motor from right to left. The motor turns the other way.

The forbidden combination. Follow the wire, not a rule. If the top-left and the bottom-left switches are both closed, the + goes straight to the −, through two closed switches and no motor. Nothing limits the current: that is a short circuit. The same goes for the two switches on the right. A good driver is built so that you cannot ask for this.

A driver board hides the four switches. The DRV8833 holds two full H-bridges, each made of two halves, and each half has its own input pin [1]. You choose among four behaviours, and every combination of the two inputs is listed with a defined result [3].

Click the switches in the widget below and watch the motor.

Click the four switches (interactive)
Click the four switches (interactive) Interactive simulation, not a real circuit. An H-bridge: the plus line on top, the minus line at the bottom, four switches you can click, S1 top-left, S2 top-right, S3 bottom-left, S4 bottom-right, and the motor in the middle; its wheel is drawn on the right. Close S1 and S4: the current path is drawn in orange and the wheel turns forward. Close S2 and S3: it turns in reverse. Close both bottom or both top switches: brake. All open: coast. Close two switches on the same side, S1 and S3 or S2 and S4: a red short-circuit path appears, the bridge is greyed out and the text says this combination is not allowed. simulation, not a real circuit+−S1S3S2S4Mwheel

Simulation: switches you can click, not a real circuit.

Statecoast

No closed path through the motor: it is let go and spins down slowly.

The DRV8833 never lets you pick a forbidden pair: its two inputs only choose among the four allowed behaviours.

This is the starting state: the controls need JavaScript.

Four switches around the motor: an H Top: the H-bridge drawn as an H. The plus line on top, the minus line at the bottom, a switch on each of the four arms: S1 top-left, S2 top-right, S3 bottom-left, S4 bottom-right; the motor is the crossbar. Below, three small copies. a, forward: S1 and S4 closed, the current goes from plus through S1, through the motor left to right, through S4 to minus, drawn as an orange band. b, reverse: S2 and S3 closed, the current goes through the motor right to left. c, forbidden: S1 and S3 closed: plus goes straight to minus through two switches and no motor, a short circuit, drawn as a bold red dashed path with a cross. FIG. 2 — THE H-BRIDGE+−S1S3S2S4MAll switches open: the motor is free.aForward: S1 + S4+−S1S3S2S4MbReverse: S2 + S3+−S1S3S2S4McForbidden: S1 + S3+−S1S3S2S4Mshort circuit!
Tap the diagram to open it full screen.

The DRV8833 board

The Adafruit DRV8833 board packs two H-bridges, so it can drive two DC motors or one stepper motor [1]. Here is what matters for a small motor:

  • Current. It is for motors that need about 1.2 A or less per channel. The board is set up to limit each channel to about 1 A [1][2].
  • Motor power. The motor supply goes to the screw terminal and may be between 2.7 V and 10.8 V [1][2]. The terminal’s + side has a simple protection against polarity mistakes, but the bare VM pin does not [2]: so bring the motor power in through the screw terminal.
  • Logic level. The inputs accept 2.7 V or more, so the ESP32’s 3.3 V signals work even if the motors run from a higher voltage [1][2].
  • Inputs. AIN1 and AIN2 control motor A, BIN1 and BIN2 control motor B [2]. We use motor A.
  • Sleep pin. SLP is pulled low inside the board, so the chip is asleep until you drive SLP high [2].
  • Protection. The chip has built-in diodes that absorb the kick a motor makes when it is switched off, so you do not have to add one [1]. We will meet this kick in lesson C2.
  • GND is shared between the logic and the motor supply [2].

The board has a fault pin (FLT) too [2]. We leave it unconnected in this lesson.

The DRV8833 board: what each pin does Top view of a DRV8833 motor driver board, our own drawing with the pin labels of Adafruit's breakout. Power side: the screw terminal VMotor, plus and minus, motor supply from 2.7 to 10.8 V, protected against a polarity mistake on its plus side; the bare VM pin is not protected; GND is shared by the logic and the motors. Logic side: AIN1 and AIN2 for motor A, BIN1 and BIN2 for motor B, inputs of 2.7 V or more; SLP, sleep, pulled low on the board: high means awake; FLT, the fault output, not used in this lesson. Motor outputs: AOUT1 and AOUT2 for motor A, BOUT1 and BOUT2 for motor B. Each channel is limited to about 1 A. FIG. 3 — THE DRV8833 BOARDDRV8833+−VMotorVMGNDAIN1AIN2BIN1BIN2SLPFLTAOUT1AOUT2BOUT2BOUT1motor Amotor Bmotor outputspowerinputs: 2.7 V or moreAIN → motor A, BIN → motor BSLP: high = awakeFLT: fault output,not used here2.7 to 10.8 Vmotor supply+ side protectedagainst polarityVM pin: not protected,use the terminalGND: shared by logic and motorsabout 1 Aper channelOwn drawing: check the labels printed on your board.
Tap the diagram to open it full screen.

Four behaviours, and speed

For one motor, the two inputs give four behaviours [3]:

AIN1 AIN2 What the motor does
low low coast: the motor is let go and spins down slowly
high low forward
low high reverse
high high brake: the motor is held

Which direction is “forward” depends on how you wired the motor. Swapping its two wires flips it [3].

Speed. To go slower, keep one input low and switch the other one on and off quickly: that is PWM, the trick from lesson A2 [3]. A longer “on” share means more speed. With AIN1 as the PWM pin, the motor goes forward; with AIN2, it goes in reverse [3].

Coast or brake. The table has two ways to stop. Coasting cuts the motor’s power and lets it spin down [7]. Braking uses the electricity the spinning motor makes itself, which slows it down quickly [7]. Adafruit calls the two ways of using PWM “fast decay” (the input is low in the off part, so the motor coasts during it) and “slow decay” (the input is high in the off part, so the motor is braked during it) [3][7]. We use the first one, the simplest.

A reminder from lesson A2: the duty cycle is the share of each period that the signal is on.

Two inputs, four behaviours, and speed Top, the truth table as four small panels, each with the two input levels drawn as high or low bars and the result on the wheel. AIN1 low, AIN2 low: coast, the wheel turns freely and spins down. AIN1 high, AIN2 low: forward, a clockwise arrow. AIN1 low, AIN2 high: reverse, an anticlockwise arrow. Both high: brake, a lock: the motor is held. Bottom, speed: a PWM signal on AIN1 with AIN2 low. At 30 % duty the wheel turns slowly, one short arrow; at 80 % it turns quickly, a long arrow. Which way is forward depends on how the motor is wired. FIG. 4 — THE FOUR BEHAVIOURScoastAIN1lowAIN2lowfree, spins downforwardAIN1highAIN2lowturns one wayreverseAIN1lowAIN2highturns the other waybrakeAIN1highAIN2highheld stillsSpeed: PWM on AIN1, AIN2 low30 %AIN1AIN2slow80 %AIN1AIN2fast
Tap the diagram to open it full screen.

Power and wiring: keep it small

Motors are hungry and noisy. The rules:

  • The motor gets its own supply. The DRV8833’s guide says its motor supply gets noisy, and suggests separate supplies when you have sensitive parts [2]. The Adafruit motor lesson also says a more powerful motor should get a separate supply [5]. For small TT motors rated 3 to 6 V [6], a holder of 4 NiMH AA cells with an on/off switch gives 4.8 V (see lessons E4 and A2) [9]. Do not power the motor from the ESP32’s pins.
  • Join the grounds. The ground of the motor supply goes to the driver’s GND and to a GND pin of the ESP32 [2][5]. Without it, the signals have no shared zero.
  • Small motors only. This board suits motors that need about 1.2 A or less [1]. A TT motor draws about 150 mA free-running at 4.5 V, but about 1.2 A when stalled [6]: that is the board’s whole rating. The board’s current limit of about 1 A per channel is what keeps it safe, and Adafruit recommends this driver for TT motors for exactly that reason [2][6]. Never solder the jumpers on the back of the board closed: that turns the limit off [2]. And never hold the wheel still while the motor is powered: the motor and the pack still heat up. Anything bigger than a TT or similar hobby motor needs a different driver, and not this lesson.
  • Check polarity twice before switching on, and wire everything with the supply switched off.

The wiring: AIN1 on GPIO 25, AIN2 on GPIO 26, SLP on GPIO 33, a button on GPIO 27 (other leg to GND), the motor on the two outputs of channel A. Use the labels printed on your board.

A3 wiring: DRV8833 on 25, 26, 33, motor on its own 4.8 V pack, common GND Two panels. a, build view. The DevKitC sits off the breadboard, below it, USB on the left, powered by its USB cable; female jumpers go on its top pins. The DRV8833 board straddles the breadboard's centre channel, rows 5 to 19, our own drawing with the labels of Adafruit's board. Its logic pins are in column e: VM row 6, GND row 7, AIN1 row 8, AIN2 row 9, BIN1 row 10, BIN2 row 11, SLP row 12, FLT row 13; its motor outputs in column f: AOUT1 row 15, AOUT2 row 16. 1 yellow, GPIO 25 to AIN1; 2 green, GPIO 26 to AIN2; 3 white, GPIO 33 to SLP. 4 black, the board's GND row to the bottom minus rail. 5 black, a thick wire labelled common GND, from a GND pin of the DevKitC to the minus rail. The button straddles the channel in rows 1 and 3: 6 blue, GPIO 27 to row 3; 7 black, row 1 to the minus rail. The motor's two wires go to rows 15 and 16, AOUT1 and AOUT2. A holder of 4 NiMH AA cells, 4.8 V, with a switch, off while you wire: its red lead to the screw terminal's plus, its black lead to the minus, which is the board's GND. A dashed red line from the 3V3 pin, crossed out: never power the motor from 3V3. b, schematic: GPIO 25 to AIN1, GPIO 26 to AIN2, GPIO 33 to SLP. The motor between AOUT1 and AOUT2. The battery, 4 NiMH, 4.8 V, with its switch, feeds the VMotor terminal. A bold line joins the battery's minus, the DRV8833's GND and the ESP32's GND: common GND. The button sits between GPIO 27 and GND. A crossed-out dashed line from 3V3 to the motor power. FIG. 5 — WIRING, MOTOR ON ITS OWN SUPPLYaBuild view+−−+jihgfedcba15101520VMGNDAIN1AIN2BIN1BIN2SLPFLTAOUT1AOUT2BOUT2BOUT1DRV8833 board+−4 × NiMH AA, 4.8 V++++ONOFFMmotor(TT, 3 to 6 V)buttonENBOOT5VCLKCMDD0D3D1D215132GND0124141627172652518331932GND352134RXVNTXVP22EN233V3GNDcommon GND3V3 → motor: neverGND27262533GNDGNDUSB cable:powers theboard12345671yellow: GPIO 25 → AIN1 (row 8)2green: GPIO 26 → AIN2 (row 9)3white: GPIO 33 → SLP (row 12)4black: DRV8833 GND (row 7) → − rail5black: GND pin → − rail: common GND6blue: GPIO 27 → button (row 3)7black: button, other leg (row 1) → − railPack leads go to the screw terminal: red to +, black to − (the board's GND). Motor wires: rows 15 and 16.The motor's power never touches a pin of the DevKitC. Pack off while you wire; check polarity twice.bSchematicESP323V325263327GNDDRV8833AIN1AIN2SLPGNDVMotorAOUT1AOUT2M+4 × NiMH4.8 Vswitchcommon GNDbuttonnever: 3V3 does not power the motor
Tap the diagram to open it full screen.

Command the motor

Wire it as in the diagram. Keep the motor free to turn, with the wheel in the air or no wheel at all, and switch the pack on only when you have checked everything.

The ESP32 has hardware for generating PWM, the LEDC peripheral [8]. We use the same two functions as in lesson A2: ledcAttach() and ledcWrite(). Here, one channel is set up for each input, at 1000 pulses per second and 8 bits, so the duty runs from 0 to 255 [8].

// Tinker Mission, lesson A3: drive one small DC motor with a DRV8833 board (forward, coast, reverse, brake)
// Wiring (the motor has its OWN power: never take it from the ESP32 board):
//   DRV8833 AIN1 -> GPIO 25
//   DRV8833 AIN2 -> GPIO 26
//   DRV8833 SLP  -> GPIO 33   (sleep pin: HIGH = driver awake)
//   DRV8833 GND  -> a GND pin of the ESP32 AND the - of the motor supply (common ground)
//   Motor supply + -> the + screw terminal of the DRV8833 (motor power, 2.7 to 10.8 V; e.g. 4 NiMH AA = 4.8 V)
//   Motor supply - -> the - (GND) screw terminal of the DRV8833
//   (use the labels printed on YOUR board, and check the polarity twice before you switch on)
//   Motor wires -> the two OUT screw terminals of channel A (AOUT1 and AOUT2); swapping them only flips the direction
//   Button: one leg to GPIO 27, the diagonally opposite leg to GND (no resistor needed)
// Each press goes to the next mode: forward, coast, reverse, brake, forward, and so on.
// Forward and reverse run at SPEED (a number from 0 to 255) using the board's PWM hardware (LEDC).

const int AIN1_PIN = 25;
const int AIN2_PIN = 26;
const int SLEEP_PIN = 33;
const int BUTTON_PIN = 27;

const int PWM_FREQ = 1000;      // 1000 pulses per second
const int PWM_BITS = 8;         // duty from 0 (always off) to 255 (always on)
const int MAX_DUTY = 255;

const int SPEED = 170;          // 0 to 255; about two thirds of full speed

enum Mode { FORWARD, COAST, REVERSE, BRAKE, MODE_COUNT };
const char* MODE_NAMES[] = { "forward", "coast", "reverse", "brake" };

Mode mode = COAST;
bool wasPressed = false;

// Write the two input levels (0 = low, 255 = high, in between = PWM).
void setInputs(int in1, int in2) {
  ledcWrite(AIN1_PIN, in1);
  ledcWrite(AIN2_PIN, in2);
}

void applyMode(Mode m) {
  switch (m) {
    case FORWARD: setInputs(SPEED, 0); break;               // IN1 = PWM, IN2 = low
    case REVERSE: setInputs(0, SPEED); break;               // IN1 = low, IN2 = PWM
    case COAST:   setInputs(0, 0); break;                   // both low: the motor is free
    case BRAKE:   setInputs(MAX_DUTY, MAX_DUTY); break;     // both high: the motor is held
    default: break;
  }
  Serial.print("mode: ");
  Serial.print(MODE_NAMES[m]);
  if (m == FORWARD || m == REVERSE) {
    Serial.print(", speed ");
    Serial.print(SPEED * 100 / MAX_DUTY);
    Serial.print(" %");
  }
  Serial.println();
}

void setup() {
  Serial.begin(115200);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(SLEEP_PIN, OUTPUT);
  ledcAttach(AIN1_PIN, PWM_FREQ, PWM_BITS);   // pin, frequency, resolution (bits)
  ledcAttach(AIN2_PIN, PWM_FREQ, PWM_BITS);
  applyMode(COAST);                           // start with the motor free
  digitalWrite(SLEEP_PIN, HIGH);              // wake the driver up
}

void loop() {
  bool pressed = (digitalRead(BUTTON_PIN) == LOW);
  if (pressed && !wasPressed) {               // just pressed (not held)
    mode = (Mode)((mode + 1) % MODE_COUNT);
    applyMode(mode);
  }
  wasPressed = pressed;
  delay(20);                                  // also hides contact bounce
}

Download the sketch folder (.zip)

Open the Serial Monitor at 115200 baud. Each press goes to the next mode and prints its name.

How to read it:

  • setInputs(in1, in2) writes one duty value to each input: 0 means low, 255 means high, and a number in between means PWM.
  • Forward is setInputs(SPEED, 0): AIN1 gets the PWM, AIN2 stays low, as in the table [3]. Reverse swaps them.
  • Coast is setInputs(0, 0). Brake is setInputs(MAX_DUTY, MAX_DUTY).
  • The modes go forward, coast, reverse, brake: the motor is never asked to switch directly from one direction to the other. That is our choice, so you can see each behaviour.
  • SLEEP_PIN stays low until setup() has set the mode, then goes high, so the driver wakes up with the motor free [2].
  • The button works by edge, as in lesson A2: one move per press.
One press, the next mode The four modes of the sketch as a loop of four stations, joined by arrows labelled press: forward, then coast, then reverse, then brake, then back to forward. Under each station, the two inputs: forward, AIN1 PWM 170 and AIN2 low; coast, both low, 0 and 0; reverse, AIN1 low and AIN2 PWM 170; brake, both high, 255 and 255. The sketch starts at coast. The motor never goes straight from one direction to the other. FIG. 6 — THE MODE LOOPforwardAIN1PWM 170AIN20AIN1 = PWM, AIN2 lowcoastAIN10AIN20both lowreverseAIN10AIN2PWM 170AIN1 low, AIN2 = PWMbrakeAIN1255AIN2255both highpresspresspresspressstartPWM 170 out of 255 ≈ 66 %. Never straight from one direction to the other.
Tap the diagram to open it full screen.

Try your own changes

Change one thing, upload, observe.

  1. Another speed. Change SPEED to 100, then 255. Does the motor change speed in proportion? At low values, does it even start? (A test with one TT motor found that it did not start until a certain level, and at low speed behaved differently from higher speeds [7].)
  2. Swap the wires. With the supply off, swap the two motor wires. What changes? [3]
  3. Brake or coast? Run the motor forward, then press for coast: count how long the wheel takes to stop. Do the same with brake. Which stops faster? [7]
  4. A ramp. Replace the fixed SPEED with a loop that goes from 0 to 255, adding 1 every 10 ms, as in Adafruit’s example [3]. Why does a slow ramp feel gentler?
  5. Two motors. Add the second channel (BIN1 and BIN2 on two more pins, motor B on its outputs) and make a tank turn: one wheel forward, one wheel in reverse.

When it does not work

  • Nothing moves, not even a hum. Check that SLP is high: without it the chip stays inactive [2]. Check the motor supply is on and its ground is joined to the board’s ground [2][5].
  • The motor runs the wrong way. Swap its two wires [3], or swap the two modes in the code.
  • It hums or twitches at low speed. The motor may need a stronger push to get started: raise SPEED [7].
  • The driver gets hot, or the motor stops and starts again. The board limits the current of each channel, and it shuts down on overheating or too much current; its fault pin (FLT, unconnected here) reports this [2]. Switch off, check that the motor is not jammed, and use a smaller motor if needed [1].
  • It only runs one way. One of the two input wires is on the wrong pin or loose. Check GPIO 25 and 26.
  • “ledcAttach was not declared” when you compile. Your esp32 board package is too old. Update “esp32 by Espressif Systems” to version 3 or later: ledcAttach() arrived with version 3 [10].
  • Nothing in the Serial Monitor. Set it to 115200 baud, the same as Serial.begin(115200).

Check yourself

Three short questions. Nothing is saved, take your time.

  1. On the DRV8833 board, both inputs of a channel (AIN1 and AIN2) are set high. What does the motor do?

    • It runs forward at full speed
    • It is held, like a brake
    • It runs in reverse
    Show the answer

    It is held, like a brake. In the driver's logic table, both inputs high is the brake case [3]. Both inputs low is coast, and one high with the other low is forward or reverse [3].

  2. Your code runs, the inputs change, but the motor never moves. What is a good first thing to check?

    • That the SLP pin is held high, because the board sleeps by default
    • That the motor wires are the right colours
    • That the Serial Monitor is set to 9600 baud
    Show the answer

    That the SLP pin is held high, because the board sleeps by default. The sleep pin is pulled low inside the board, so the chip does nothing until you drive it high [2]. The order of the two motor wires only changes the direction [3].

  3. A small TT motor is held still (stalled) while powered at 4.5 V. About how much current does it draw, compared with the 1.2 A per channel the board is rated for?

    • About 0.15 A, much less than the rating
    • About 1.2 A, right at the rating
    • About 12 A, ten times the rating
    Show the answer

    About 1.2 A, right at the rating. Adafruit measured about 1.2 A for a stalled TT motor at 4.5 V, against about 150 mA with no load [6]. The board is rated for up to about 1.2 A per channel, and it is set to limit each channel to about 1 A, which is what protects it here [1][2]. Still, never hold the wheel still while it is powered.


In short

  • An H-bridge uses four switches to connect a motor to the supply in either direction. Never close both switches on the same side: that is a short circuit.
  • The DRV8833 board holds two H-bridges: two inputs per motor give coast, forward, reverse or brake [3], and the SLP pin must be high [2].
  • Put PWM on one input and keep the other low to choose the speed [3].
  • The motor has its own supply (2.7 to 10.8 V on this board), the grounds are joined, and the motor is a small one, rated about 1.2 A or less [1][2].

Next step: M3, mechanisms, to turn a spinning motor into useful movement.


Sources

Show the 10 sources
  1. Adafruit, “Adafruit DRV8833 DC/Stepper Motor Driver Breakout Board” (product ID 3297) (two full H-bridges, four half H-bridges; up to 1.2 A per channel; 2.7 V to 10.8 V motor power; set for 1 A current limiting; peak 2 A for a short time if limiting is off; built-in kick-back diodes; two digital inputs per H-bridge, one for each half; PWM one input for speed; logic 2.7 V or greater works with 3.3 V logic; polarity protection on the motor voltage input) — https://www.adafruit.com/product/3297
  2. Adafruit, “Adafruit DRV8833 DC/Stepper Motor Driver Breakout Board”, “Pinouts” (Vmotor 2.7 V to 10.8 V and noisy, keep supplies separate for noise-sensitive parts; terminal block + pin has polarity protection, VM pin does not; GND shared logic and motor ground; AIN1/AIN2 and BIN1/BIN2 inputs, 2.7 V or higher logic level; PWM the pin that is normally high; FLT fault output drives low on thermal shutdown or overcurrent; SLP pulled low by an internal 500K resistor so the chip is not active until driven high; default 1 A limit per channel; current limit = 0.2 V / RSENSE, two 0.2 Ω resistors give 1 A per channel; soldering the two jumpers on the back disables current limiting) — https://learn.adafruit.com/adafruit-drv8833-dc-stepper-motor-driver-breakout-board/pinouts
  3. Adafruit, “Adafruit DRV8833 DC/Stepper Motor Driver Breakout Board”, “Arduino DC Motor” (wiring with SLP and external motor power; motor wire order only affects direction; Table 1 H-bridge logic: 00 coast/fast decay, 01 reverse, 10 forward, 11 brake/slow decay; PWM modes: fast decay and slow decay; example ramp of the duty cycle with a 10 ms step) — https://learn.adafruit.com/adafruit-drv8833-dc-stepper-motor-driver-breakout-board/arduino-dc-motor
  4. Adafruit, “Arduino Lesson 15. DC Motor Reversing”, “An Experiment” (swapping the motor leads reverses the direction; the control pins do the equivalent of swapping; both inputs low or both high stop the motor) — https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/an-experiment
  5. Adafruit, “Arduino Lesson 15. DC Motor Reversing”, “L293D” (a more powerful motor gets a separate power supply, and the ground of the second supply is connected to the Arduino’s ground) — https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/lm293d
  6. Adafruit, “DC Gearbox Motor - TT Motor - 200RPM - 3 to 6VDC” (product ID 3777) (powered by 3 V to 6 V; at 4.5 V one sample drew 155 mA with no load and 1.2 A when stalled; 1.1 A stalled at 3 V and 1.5 A at 6 V; Adafruit recommends the DRV8833 for these motors because it can limit the current, since the stall current can get high) — https://www.adafruit.com/product/3777
  7. Adafruit, “Improve Brushed DC Motor Performance” (fast decay: the motor coasts when switched off; slow decay brakes using the motor’s own generated current, and the DRV8833 brakes actively in slow decay; a TT motor test: a spin threshold in fast decay, and a different behaviour at low speed with slow decay; TT motor test on the Motor Performance Charts page) — https://learn.adafruit.com/improve-brushed-dc-motor-performance/current-decay-mode
  8. Espressif, Arduino-ESP32 documentation, “LED Control (LEDC)” (ledcAttach(pin, freq, resolution) with resolution 1-14 bits, 1-20 bits for ESP32; ledcWrite(pin, duty) sets the duty; example with 1000 Hz and 8 bits) — https://docs.espressif.com/projects/arduino-esp32/en/latest/api/ledc.html
  9. Adafruit, “Adafruit NeoPixel Überguide”, “Powering NeoPixels” (four NiMH cells in a 4-cell holder give 4.8 V; four alkaline cells give 6 V) — https://learn.adafruit.com/adafruit-neopixel-uberguide/powering-neopixels
  10. Espressif, Arduino-ESP32 documentation, “Migration from 2.x to 3.0”, “LEDC” (the old LEDC API, ledcSetup and ledcAttachPin, was removed and replaced by ledcAttach() in version 3.0) — https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html

Pinch or double-tap to zoom, swipe to change diagram.Scroll with Ctrl or double-click to zoom. Arrow keys change diagram.