Arduino Giga R1 WiFi DRV8833 DC Motor Driver

In this guide, we will learn how to use the DRV8833 motor driver with the Arduino Giga R1 WiFi to spin small DC motors in both directions at any speed. In detail, we will learn:

Arduino Giga R1 WiFi and DRV8833 DC motor driver module

The Giga R1 WiFi runs its pins at 3.3V. Many older motor drivers want 5V signals, but the DRV8833 is happy with 3.3V. So you can wire it straight to the Giga, with no level shifter in between.

Hardware Preparation

1×Arduino Giga R1 WiFi
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×DRV8833 Motor Driver Module
2×DC Motor (e.g., 5V)
1×5V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×Recommended: Screw Terminal Block Shield for Arduino Uno/Mega/Giga
1×Recommended: Sensors/Servo Expansion Shield for Arduino Mega/Giga
1×Recommended: Breadboard Shield for Arduino Mega/Giga
1×Recommended: Enclosure for Arduino Giga
1×Recommended: Power Splitter for Arduino Giga

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

You need the second motor only for Part 2.

Overview of DRV8833 Motor Driver

A pin of the Giga R1 WiFi can give only a few milliamps. A DC motor needs hundreds of milliamps, and it must be able to turn both ways. The DRV8833 from Texas Instruments sits in the middle. It has two H-bridges inside, so one small module controls two DC motors on their own. (It can also run one bipolar stepper motor, but this guide sticks to DC motors.)

Inside the chip, MOSFET switches do the work. They have a low resistance (about 360 mΩ for the high side and low side together), so they lose little voltage and stay cool. That is a big plus over the old L298N when you power a robot from 3V to 9V batteries.

Feature DRV8833
Motor supply (VCC pin) 2.7V to 10.8V
Logic supply none needed, made inside the chip
Control signals 3.3V or 5V
Output current about 1.5A RMS per channel, 2A peak (with good cooling)
Number of DC motors 2
PWM frequency up to 50 kHz
Protection under-voltage lockout, over-current, thermal shutdown

If one motor needs more current, you can join the two channels together for about 3A. That is an advanced setup, and we do not use it here.

Pinout

DRV8833 motor driver module pinout

Control pins (to the Giga R1 WiFi):

  • IN1, IN2 pins: control motor A. Connect to two PWM pins of the Giga.
  • IN3, IN4 pins: control motor B. Connect to two more PWM pins of the Giga.
  • EEP pin (sleep, also called nSLEEP or SLP): the driver works only when this pin is HIGH. Connect to the 3.3V pin of the Giga. LOW puts the chip to sleep.
  • ULT pin (fault, also called nFAULT or FLT): goes LOW when the chip finds a problem. It is optional. You can leave it unconnected.

Power pins:

  • VCC pin: connect to the motor power supply (2.7V to 10.8V), for example a 5V adapter.
  • GND pin: connect to the ground of the motor supply and to a GND pin of the Giga.

Motor pins:

  • OUT1, OUT2 pins: connect to the two wires of motor A.
  • OUT3, OUT4 pins: connect to the two wires of motor B.

Labels vary between sellers. Some boards print AIN1, AIN2, BIN1, BIN2, AOUT1, AOUT2 and so on. Always follow the text on your own module.

How the IN Pins Control a Motor

The DRV8833 has no ENA or ENB speed pin like the L298N. Both direction and speed come from the two IN pins of each channel:

IN1 IN2 Motor A does
LOW LOW Coast (no drive, the motor rolls to a stop)
HIGH LOW Forward
LOW HIGH Reverse
HIGH HIGH Brake (fast stop)

Motor B works the same way with IN3 and IN4.

To set the speed, send PWM to one pin and hold the other LOW:

  • Forward at part speed: PWM on IN1, IN2 LOW.
  • Reverse at part speed: IN1 LOW, PWM on IN2.

So every IN pin must be a PWM pin. That is easy on the Giga: pins D2 to D13 all support analogWrite(). This guide uses D10, D9, D6 and D5.

PART 1: Control One DC Motor

Wiring Diagram

The Giga R1 WiFi sends only the control signals. The 5V adapter powers the motor through the VCC pin of the module.

The wiring diagram between Arduino Giga R1 WiFi DRV8833 one motor

This image is created using Fritzing. Click to enlarge image

DRV8833 Pin Goes To
IN1 Arduino Giga R1 WiFi pin D10
IN2 Arduino Giga R1 WiFi pin D9
EEP Arduino Giga R1 WiFi 3.3V
GND Arduino Giga R1 WiFi GND and 5V adapter negative (via DC power jack)
VCC 5V adapter positive (via DC power jack)
OUT1, OUT2 The two wires of the DC motor
ULT Not connected

Important points:

  • The adapter GND, the module GND and the Giga GND must all be joined. Without a shared ground, the IN signals have no reference and the motor will not move.
  • Do not take motor power from the 5V or 3.3V pin of the Giga. A motor pulls large spikes of current that can reset or harm the board.
  • If the motor turns the wrong way, swap its two wires on OUT1 and OUT2.

How To Program For DRV8833

The sketch needs no library. Only pinMode(), digitalWrite() and analogWrite() from the Arduino core.

  • Choose the two PWM pins wired to IN1 and IN2:
const int IN1_PIN = 10; const int IN2_PIN = 9;
  • Set both pins as outputs:
pinMode(IN1_PIN, OUTPUT); pinMode(IN2_PIN, OUTPUT);
  • Spin forward at a speed from 0 to 255:
analogWrite(IN1_PIN, speed); digitalWrite(IN2_PIN, LOW);
  • Spin in reverse:
digitalWrite(IN1_PIN, LOW); analogWrite(IN2_PIN, speed);
  • Coast (free stop):
digitalWrite(IN1_PIN, LOW); digitalWrite(IN2_PIN, LOW);
  • Brake (fast stop):
digitalWrite(IN1_PIN, HIGH); digitalWrite(IN2_PIN, HIGH);

The full sketch puts the first three cases into one helper, motorRun(speed). A positive speed means forward, a negative speed means reverse, and 0 means coast.

Arduino Giga R1 WiFi Code - One DC Motor

What the sketch does in each loop:

  1. Speeds up forward from 0 to 255, step by step.
  2. Holds full speed for 2 seconds.
  3. Coasts for 2 seconds.
  4. Runs in reverse at speed 180 for 2 seconds.
  5. Brakes for 2 seconds, then starts again.
/* * This Arduino Giga R1 WiFi code was developed by newbiely.com * * This Arduino Giga R1 WiFi code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-giga/arduino-giga-r1-wifi-drv8833-dc-motor-driver */ // Arduino Giga R1 WiFi pins connected to the DRV8833 module (motor A channel) // Both pins must support PWM. On the Giga R1 WiFi, pins D2 to D13 can do PWM. const int IN1_PIN = 10; // DRV8833 IN1 const int IN2_PIN = 9; // DRV8833 IN2 // Speed is a signed number from -255 to 255: // > 0 : forward (PWM on IN1, IN2 stays LOW) // < 0 : reverse (IN1 stays LOW, PWM on IN2) // = 0 : coast (both pins LOW, motor rolls to a stop) void motorRun(int speed) { speed = constrain(speed, -255, 255); if (speed > 0) { analogWrite(IN1_PIN, speed); digitalWrite(IN2_PIN, LOW); } else if (speed < 0) { digitalWrite(IN1_PIN, LOW); analogWrite(IN2_PIN, -speed); } else { digitalWrite(IN1_PIN, LOW); digitalWrite(IN2_PIN, LOW); } } // Both pins HIGH = brake: the motor stops quickly void motorBrake() { digitalWrite(IN1_PIN, HIGH); digitalWrite(IN2_PIN, HIGH); } void setup() { Serial.begin(9600); pinMode(IN1_PIN, OUTPUT); pinMode(IN2_PIN, OUTPUT); motorRun(0); // start with the motor stopped Serial.println("DRV8833 - one DC motor demo"); } void loop() { // 1. Forward: increase the speed slowly from 0 to 255 Serial.println("Forward: speeding up"); for (int speed = 0; speed <= 255; speed += 5) { motorRun(speed); delay(20); } // 2. Hold full speed for 2 seconds Serial.println("Forward: full speed"); delay(2000); // 3. Coast: cut the drive and let the motor roll to a stop Serial.println("Coast"); motorRun(0); delay(2000); // 4. Reverse at about 70% speed Serial.println("Reverse: speed 180"); motorRun(-180); delay(2000); // 5. Brake: fast stop Serial.println("Brake"); motorBrake(); delay(2000); }

Detailed Instructions

Follow these instructions step by step:

  • New to this board? Set it up first with the Arduino Giga R1 WiFi getting started guide.
  • Wire the components according to the provided diagram. Leave the 5V adapter unplugged for now.
  • Plug the Giga R1 WiFi into your computer with the USB Type-C cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Giga R1 WiFi board (e.g., Arduino Giga R1 WiFi) and COM port.
  • Paste the code above into a new sketch.
  • Press the Upload button and wait until the upload is done.
  • Plug in the 5V adapter.
  • Open the Serial Monitor at 9600 baud.
  • Watch the motor: it speeds up, runs fast, rolls to a stop, turns the other way, then stops sharply.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Giga R1
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Giga R1' on 'COM15')
New Line
9600 baud
DRV8833 - one DC motor demo Forward: speeding up Forward: full speed Coast Reverse: speed 180 Brake Forward: speeding up Forward: full speed Coast Reverse: speed 180 Brake
Ln 11, Col 1
Arduino Giga R1 on COM15
2

Notice the difference between "Coast" and "Brake". In coast mode the shaft keeps turning for a moment. In brake mode it stops almost at once.

The motor only hums at low speed? Small motors often need a speed value of about 60 to 80 before they start to turn. This is normal.

PART 2: Control Two DC Motors

Now we use the second channel too. Think of a small robot car: motor A drives the left wheel and motor B drives the right wheel.

Wiring Diagram

Keep the Part 1 wiring and add the second motor plus two more control wires.

The wiring diagram between Arduino Giga R1 WiFi DRV8833 two motors

This image is created using Fritzing. Click to enlarge image

DRV8833 Pin Goes To
IN1 Arduino Giga R1 WiFi pin D10
IN2 Arduino Giga R1 WiFi pin D9
IN3 Arduino Giga R1 WiFi pin D6
IN4 Arduino Giga R1 WiFi pin D5
EEP Arduino Giga R1 WiFi 3.3V
GND Arduino Giga R1 WiFi GND and 5V adapter negative (via DC power jack)
VCC 5V adapter positive (via DC power jack)
OUT1, OUT2 Motor A (left wheel)
OUT3, OUT4 Motor B (right wheel)

Two motors draw about twice the current of one. Use an adapter that can give enough current for both, and remember the limit of about 1.5A per channel.

Arduino Giga R1 WiFi Code - Two DC Motors

The sketch has two helpers, motorA(speed) and motorB(speed). Each one takes a speed from -255 to 255. Turning is done by running the wheels in opposite directions:

  • Turn left: motor A in reverse, motor B forward.
  • Turn right: motor A forward, motor B in reverse.
/* * This Arduino Giga R1 WiFi code was developed by newbiely.com * * This Arduino Giga R1 WiFi code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-giga/arduino-giga-r1-wifi-drv8833-dc-motor-driver */ // Arduino Giga R1 WiFi pins connected to the DRV8833 module // All four pins must support PWM. On the Giga R1 WiFi, pins D2 to D13 can do PWM. const int IN1_PIN = 10; // motor A (left wheel) const int IN2_PIN = 9; // motor A (left wheel) const int IN3_PIN = 6; // motor B (right wheel) const int IN4_PIN = 5; // motor B (right wheel) const int DRIVE_SPEED = 200; // speed used in this demo (0 to 255) // Drive one channel with a signed speed from -255 to 255 // > 0 forward, < 0 reverse, 0 coast void driveChannel(int pinA, int pinB, int speed) { speed = constrain(speed, -255, 255); if (speed > 0) { analogWrite(pinA, speed); digitalWrite(pinB, LOW); } else if (speed < 0) { digitalWrite(pinA, LOW); analogWrite(pinB, -speed); } else { digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); } } void motorA(int speed) { driveChannel(IN1_PIN, IN2_PIN, speed); } void motorB(int speed) { driveChannel(IN3_PIN, IN4_PIN, speed); } void setup() { Serial.begin(9600); pinMode(IN1_PIN, OUTPUT); pinMode(IN2_PIN, OUTPUT); pinMode(IN3_PIN, OUTPUT); pinMode(IN4_PIN, OUTPUT); motorA(0); // both motors stopped at start motorB(0); Serial.println("DRV8833 - two DC motors (robot car) demo"); } void loop() { Serial.println("Car: forward"); motorA(DRIVE_SPEED); motorB(DRIVE_SPEED); delay(2000); Serial.println("Car: backward"); motorA(-DRIVE_SPEED); motorB(-DRIVE_SPEED); delay(2000); Serial.println("Car: turn left"); // left wheel back, right wheel forward motorA(-DRIVE_SPEED); motorB(DRIVE_SPEED); delay(1000); Serial.println("Car: turn right"); // left wheel forward, right wheel back motorA(DRIVE_SPEED); motorB(-DRIVE_SPEED); delay(1000); Serial.println("Car: stop"); motorA(0); motorB(0); delay(2000); }

Detailed Instructions

  • Add the second motor and the IN3 and IN4 wires as shown in the diagram.
  • Upload the new sketch with the 5V adapter unplugged.
  • Plug in the adapter and open the Serial Monitor at 9600 baud.
  • Watch both motors follow the forward, backward, left, right and stop pattern.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
Arduino Giga R1
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Giga R1' on 'COM15')
New Line
9600 baud
DRV8833 - two DC motors (robot car) demo Car: forward Car: backward Car: turn left Car: turn right Car: stop Car: forward Car: backward Car: turn left Car: turn right Car: stop
Ln 11, Col 1
Arduino Giga R1 on COM15
2

If one wheel turns the wrong way during "forward", swap the two wires of that motor only. You do not need to change the code.

Next step: the Giga R1 WiFi has built-in Wi-Fi and Bluetooth, so you can later send these drive commands from your phone. For a plug-on shield instead of a breakout module, see the Arduino Giga R1 WiFi - DC Motor Shield tutorial. For a motor that turns in one direction only, the Arduino Giga R1 WiFi - MOSFET Module tutorial is a simpler choice.

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!