Motor Driver and Motors
Overview
Wire and test a two-motor drive system, then use a custom function to control direction and drive level.
Builds on
Before You Start
Use the classroom Maker Drive motor driver. The terminal names and wiring here are specific to that board.
Materials
- Arduino Uno R3, USB cable, and Arduino IDE
- Maker Drive motor driver, two TT motors, battery holder, and suitable batteries
- Jumper wires, screwdriver, and tape
Safety
Disconnect power before rewiring
Unplug Arduino USB and disconnect or switch off every other supply before changing wires. Check polarity and connections before restoring power.
You've got it when…
- Both motors respond to the driver buttons in the intended forward and reverse directions.
- The custom setSpeed() function reproduces the original program’s motion.
- Your notebook contains the actual power and control wiring tables and complete final code.
Collaboration & AI
Compare observations and troubleshoot with classmates. Each student must understand the wiring or design and prepare their own submission.
AI — AIAS Level 1, No AI: Complete the code or design yourself without AI assistance. AI Assessment Scale
Motor Overview and Preparation
A TT gearmotor converts electrical energy into mechanical motion. Current creates magnetic fields that turn the motor, and gears change its output speed and torque. Within its rated operating range, increasing voltage generally increases speed; reversing polarity reverses direction.
-
Inspect the motors and leave the wire ties in place. The solder joints are delicate: do not cut the wire ties.

-
Identify the wheel side of each motor by the protrusion around the shaft. Tape both motors to the table with those protrusions facing outward; keep shafts clear so they can turn.

Wire the Motor Driver
-
Review the connections overview. The microcontroller in this diagram is your Arduino. The motor driver switches battery power to the motors; the Arduino provides control signals.

The overview shows a
5Vconnection to the microcontroller. Leave that wire disconnected in this USB-powered lab, as specified in Table 3. Follow the tables for wire colors and Arduino pin numbers. -
Slide the battery holder switch to OFF and disconnect Arduino USB power.

-
Connect the power stage using Table 1. Tighten screw terminals only enough to hold each wire through a gentle tug; do not overtighten.
Table 1. Power stage connections
Motor driver screw terminal Connection M1A Right motor, black M1B Right motor, red M2A Left motor, black M2B Left motor, red VB+ Battery pack + (red) VB− Battery pack − (black) -
Install the batteries. The flat negative end contacts the spring in each slot. Notice that neighboring batteries face opposite directions. Why?

Test and Calibrate Motor Direction
-
Check the wiring, switch the battery holder ON, and press each motor-driver button separately. Compare the motion with Table 2. “Forward” means the direction that would move the robot forward with the motors mounted on their intended sides.
Table 2. Motor driver buttons
Motor driver button Desired action M1A Right motor forward M1B Right motor reverse M2A Left motor forward M2B Left motor reverse -
If a motor turns the wrong way, switch the battery holder OFF before swapping that motor's two wires at the screw terminals. Switch it back on and retest. Correct the wiring so that forward in software will mean forward on the robot.
The motors do not know which side of the robot they occupy. Moving a motor to the opposite side can reverse what counts as forward.
Control the Motors in Software
-
Switch the battery holder OFF and disconnect Arduino USB power. Make the connections in Table 3 using the Arduino Pinout. Keep the motor driver's
5Vpin disconnected; the Arduino will use USB power in this lab. The sharedGNDconnection is required.Open the complete wiring diagram full-size. The selected Arduino pins are grouped for clarity; follow their labels and the Arduino Pinout page for physical locations. The battery powers the motors, USB powers the Arduino, and both share ground. The driver’s screw terminals connect to the motors; its small header pins connect to the Arduino. Wire crossings are not electrical junctions.
Table 3. Arduino connections
Motor driver pin Arduino pin M1A 5 M1B 6 5V Leave disconnected for this lab GND GND M2A 10 M2B 11 Each motor uses two control signals: one for forward and one for reverse. These Arduino pins support pulse-width modulation (PWM). Rather than producing a steady intermediate voltage, PWM switches rapidly between
HIGHandLOW; changing the fraction of time spent high changes the motor's drive level.analogWrite()accepts values from0through255. -
Reconnect Arduino USB power and upload this program. Then switch the battery holder ON and observe the one-second changes in direction and drive level.
127is approximately half duty cycle, not a guarantee of exactly half the measured motor speed.const int pinRightMotorForward = 5; const int pinRightMotorReverse = 6; const int pinLeftMotorForward = 10; const int pinLeftMotorReverse = 11; void setup() { pinMode(pinRightMotorForward, OUTPUT); pinMode(pinRightMotorReverse, OUTPUT); pinMode(pinLeftMotorForward, OUTPUT); pinMode(pinLeftMotorReverse, OUTPUT); } void loop() { // right motor forward, full speed analogWrite(pinRightMotorForward, 255); analogWrite(pinRightMotorReverse, 0); // left motor reverse, half speed analogWrite(pinLeftMotorForward, 0); analogWrite(pinLeftMotorReverse, 127); delay(1000); // right motor reverse, half speed analogWrite(pinRightMotorForward, 0); analogWrite(pinRightMotorReverse, 127); // left motor forward, full speed analogWrite(pinLeftMotorForward, 255); analogWrite(pinLeftMotorReverse, 0); delay(1000); }
Write a Custom Function
-
Add this custom function at the end of your sketch, outside
setup()andloop(). It accepts signed speeds for the left and right motors and limits them to-255through255. Negative values reverse a motor;0stops driving it.void setSpeed(int leftSpeed, int rightSpeed) { // Make sure the speeds are within the limit. leftSpeed = constrain(leftSpeed, -255, 255); rightSpeed = constrain(rightSpeed, -255, 255); if (leftSpeed >= 0) { analogWrite(pinLeftMotorForward, leftSpeed); analogWrite(pinLeftMotorReverse, 0); } else { analogWrite(pinLeftMotorForward, 0); analogWrite(pinLeftMotorReverse, -leftSpeed); } if (rightSpeed >= 0) { analogWrite(pinRightMotorForward, rightSpeed); analogWrite(pinRightMotorReverse, 0); } else { analogWrite(pinRightMotorForward, 0); analogWrite(pinRightMotorReverse, -rightSpeed); } } -
Replace your
loop()with the following, upload, and verify that it produces the same motion as the original program. -
Copy Tables 1 and 3 into your notebook, updating the motor wire colors if you swapped them during calibration. Paste your complete final code, including constants,
setup(), the newloop(), andsetSpeed(). -
Switch the battery holder OFF and disconnect USB power before putting away or changing the circuit.
Turn It In
- Submit the following notebook entry:
- Notebook entry: Table 1 (actual power-stage wiring), Table 3 (Arduino connections), and complete final code
How It's Graded
One score from 0–4 covers the required work and evidence. Verification may be shown during the lab; the required uploads are listed above.
| Score | Evidence |
|---|---|
| 4 Excellent | Both motors have verified forward/reverse operation; setSpeed() reproduces the original motion, and both wiring tables and complete final code accurately document the tested circuit. |
| 3 Above Average | The motor operation, final code, and wiring tables are complete and working, with only minor errors or omissions in clarity or verification. |
| 2 Average | The motor operation, final code, and wiring tables have significant gaps, errors, or missing evidence. |
| 1 Below Average | The required work is largely incomplete or nonfunctional, with little usable evidence. |
| 0 Failing | No submission or no evidence of the required work. |
Converted from the original lab.