Pololu Corporation M2H24v14 User manual

Pololu Motoron Motor
Controller User’s Guide
1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Available versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2. Contacting Pololu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3. Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.1. Choosing the power supply and motor . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2. Connecting everything . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3. Enabling I²C on the Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.4. Setting I²C addresses with a Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5. Setting I²C addresses with an Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6. Writing code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4. Motoron M3S256 pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5. Motoron M3 256 pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6. LED feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7. I²C interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
8. Variable reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
9. Command reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
10. Cyclic redundancy check (CRC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
11. Reset pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
https://www.pololu.com/docs/0J84/all Page 1 of 67

1. Overview
The Motoron motor controllers are a family of general-purpose modules designed to control brushed
DC motors. The Motoron receives commands via I²C, so only two I/O lines are needed regardless of
how many Motorons you connect. The Motoron modules are designed to plug into either a Raspberry
Pi or an Arduino, and multiple Motoron controllers can be stacked on top of each other, allowing
independent control of many motors.
Motoron M3S256 Triple Motor Controller Shield
for Arduino (Connectors Soldered).
The Motoron M3S256 Triple Motor Controller Shield for Arduino, shown above, can control three
motors and is designed to plug into an Arduino [https://www.pololu.com/product/2191] or compatible
board, such as the A-Star 32U4 Prime [https://www.pololu.com/category/165/a-star-32u4-prime]. The
Motoron M3S256 can operate from 4.5 V to 48 V and has reverse-voltage protection on motor power
supply (down to −40 V). Its maximum continuous output current per motor is 2.0 A and it can provide
a peak current of 6.4 A for less than 1 second.
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 2 of 67

Motoron M3H256 Triple Motor Controller for
Raspberry Pi (Connectors Soldered).
The Motoron M3H256 Triple Motor Controller for Raspberry Pi, shown above, can control three
motors and is designed to plug into a Raspberry Pi. The Motoron M3 256 can operate from 4.5 V
to 48 V and has reverse-voltage protection on motor power supply (down to −40 V). Its maximum
continuous output current per motor is 2.0 A and it can provide a peak current of 6.4 A for less than
1 second.
Features and specifications
• Logic voltage range: 2.8 V to 5.5 V
• Control interface: I²C
• I²C clock speed: up to 400 k z
• Optional cyclic redundancy checking (CRC)
• Configurable motion parameters:
◦ Max acceleration/deceleration forward/reverse
◦ Starting speed forward/reverse
◦ Direction change delay forward/reverse
• PWM frequency: eight options available from 1 k z to 80 k z
• Command timeout feature stops motors if the Arduino stops functioning
• Configurable automatic error response
• Motor power supply (VIN) voltage measurement
• Optional pins make it easy to power the Arduino or Raspberry Pi from reverse-protected
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 3 of 67

motor power, either directly or through an external regulator [https://www.pololu.com/category/
136/voltage-regulators] (not included)
• Two status LEDs
• Motor direction indicator LEDs
•Motoron Arduino library [https://github.com/pololu/motoron-arduino] simplifies getting started
with an Arduino or compatible controller
•Motoron Python library [https://github.com/pololu/motoron-rpi] simplifies getting started with a
Raspberry Pi
1.1. Available versions
The Motoron family consists of two different controllers: the Motoron M3S256 (an shield for Arduino)
and the Motoron M3H256 (for the Rasbperry Pi).
Multiple versions of each controller are available to provide different options for the through-hole
connectors:
•Motoron M3S256 with soldered stackable headers and terminal blocks
[https://www.pololu.com/product/5030]
•Motoron M3S256 with headers and terminal blocks included but not soldered in
[https://www.pololu.com/product/5031]
•Motoron M3S256 without any headers or terminal blocks included [https://www.pololu.com/
product/5032]
•Motoron M3H256 with soldered stackable headers, soldered terminal blocks, and
standoffs [https://www.pololu.com/product/5033]
•Motoron M3H256 with headers, terminal blocks, and standoffs included but not
soldered in [https://www.pololu.com/product/5034]
•Motoron M3H256 without any standoffs, headers, or terminal blocks included
[https://www.pololu.com/product/5035]
See below for more information about these three options.
M3S256 with connectors soldered
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 4 of 67

Motoron M3S256 Triple Motor Controller Shield for Arduino
(Connectors Soldered).
The M3S256 version with connectors soldered [https://www.pololu.com/product/5030] has stackable
female headers and terminal blocks installed. This version allows you to use all the main features of
the board without additional soldering, as the motor and power leads can be connected to the board
via terminal blocks and the logic connections are made by simply plugging the shield into an Arduino.
M3S256 kit version
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 5 of 67

Motoron M3S256 Triple Motor Controller Shield Kit for Arduino.
The M3S256 kit version [https://www.pololu.com/product/5031] comes with the following connectors
included but not soldered, allowing for more installation options:
• One 1×10 stackable female header
• One 1×8 stackable female header
• Four 2-pin 3.5mm terminal blocks [https://www.pololu.com/product/2444]
• Four 2-pin 5mm screw terminal blocks [https://www.pololu.com/product/2440]
• One 1×25 male header [https://www.pololu.com/product/965]
There are more parts included than can be soldered to the board, providing different assembly options
to suit a variety of applications. Additional connector [https://www.pololu.com/category/19/connectors]
options are available separately, and wires can also be soldered directly to the board for more compact
installations.
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 6 of 67

Note: For applications where the Motoron M3S256 will be used as a standalone board or at
the top of a shield stack, it can be assembled with the included 0.1″ male header pins and
larger (5.0mm-pitch) blue terminal blocks. For applications where the Motoron will be one
of the intermediate members of a stack of shields, we recommend assembling it with the
stackable headers and smaller (3.5mm-pitch) green terminal blocks (just like our version
with connectors already soldered [https://www.pololu.com/product/5030]). The terminal blocks
are intended to be soldered to the larger through-holes for the power and motor connections,
and the blue ones should get locked together prior to installation (see our short video on
terminal block installation [https://www.youtube.com/watch?v=6pDyTLRZ2Eg]).
M3S256 with no connectors
Motoron M3S256 Triple Motor Controller Shield for Arduino (No
Connectors).
The "no connectors" version [https://www.pololu.com/product/5032] is just the PCB assembled with all of
the surface-mount components. This version is intended for those who want to solder wires directly to
the board or use a custom set of connectors [https://www.pololu.com/category/19/connectors].
M3H256 with connectors soldered
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 7 of 67

Motoron M3H256 Triple Motor Controller for Raspberry Pi
(Connectors Soldered).
The M3H256 version with connectors soldered [https://www.pololu.com/product/5033] has stackable
female headers and terminal blocks installed, and it comes with two standoffs [https://www.pololu.com/
product/1952], two screws [https://www.pololu.com/product/1968], and two hex nuts [https://www.pololu.com/
product/1967]. This version allows you to use all the main features of the board without additional
soldering, as the motor and power leads can be connected to the board via terminal blocks and the
logic connections are made by simply plugging the shield into a Raspberry Pi.
M3H256 kit version
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 8 of 67

Motoron M3H256 Triple Motor Controller Kit for Raspberry Pi.
The M3H256 kit version [https://www.pololu.com/product/5034] comes with the following connectors
included but not soldered, allowing for more installation options:
• Two 1×10 stackable female headers (or one 2×10 header)
• Four 2-pin 3.5mm terminal blocks [https://www.pololu.com/product/2444]
• Four 2-pin 5mm screw terminal blocks [https://www.pololu.com/product/2440]
• One 1×25 male header [https://www.pololu.com/product/965]
• Two standoffs [https://www.pololu.com/product/1952]
• Two screws [https://www.pololu.com/product/1968]
• Two hex nuts [https://www.pololu.com/product/1967]
There are more parts included than can be soldered to the board, providing different assembly options
to suit a variety of applications. Additional connector [https://www.pololu.com/category/19/connectors]
options are available separately, and wires can also be soldered directly to the board for more compact
installations.
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 9 of 67

Note: For applications where the Motoron M3 256 will be used as a standalone board or at
the top of a stack of boards, it can be assembled with the larger (5.0mm-pitch) blue terminal
blocks. For applications where the Motoron will be one of the intermediate members of a
stack of boards, we recommend assembling it with the smaller (3.5mm-pitch) green terminal
blocks (just like our version with connectors already soldered [https://www.pololu.com/
product/5033]). The terminal blocks are intended to be soldered to the larger through-holes
for the power and motor connections, and the blue ones should get locked together prior
to installation (see our short video on terminal block installation [https://www.youtube.com/
watch?v=6pDyTLRZ2Eg]).
M3H256 with no connectors
Motoron M3H256 Triple Motor Controller for Raspberry Pi (No
Connectors or Standoffs).
The "no connectors" version [https://www.pololu.com/product/5035] is just the PCB assembled with all of
the surface-mount components. This version is intended for those who want to solder wires directly to
the board or use a custom set of connectors [https://www.pololu.com/category/19/connectors].
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
1. Overview Page 10 of 67

2. Contacting Pololu
We would be delighted to hear from you about any of your projects and about your experience with
the Motoron. If you need technical support or have any feedback you would like to share, you can
contact us [https://www.pololu.com/contact] directly or post on our forum [https://forum.pololu.com/c/support/
pololu-motor-controllers-drivers-and-motors]. Tell us what we did well, what we could improve, what you
would like to see in the future, or anything else you would like to say!
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
2. Contacting Pololu Page 11 of 67

3. Getting started
3.1. Choosing the power supply and motor
The information in this section can help you select a power supply [https://www.pololu.com/category/84/
regulators-and-power-supplies] and motor [https://www.pololu.com/category/22/motors-and-gearboxes] that will
work with the Motoron.
The Motoron is designed to work with brushed DC motors. These motors have two terminals such
that when a DC voltage is applied to the terminals, the motor spins.
When selecting the components of your system, you will need to consider the voltage and current
ratings of each component:
• The voltage range of your power supply is the range of voltages you expect your power
supply to produce while operating. There is usually some variation in the output voltage so
you should treat it as a range instead of just a single number. In particular, keep in mind that a
fully-charged battery might have a voltage that is significantly higher than its nominal voltage.
• The current limit of a power supply is how much current the power supply can provide.
Note that the power supply will not force this amount of current through your system; the
properties of the system and the voltage of the power supply determine how much current
will flow, but there is a limit to how much current the power supply can provide.
• The operating voltage range of a Motoron is the range of voltages that can be supplied
to the Motoron’s VIN and GND pins, which power the motors. The operating voltage range
of the Motoron M3S256 and M3 256 is 4.5 V to 48 V. The Motoron requires a DC power
supply.
• The continuous current per motor of a Motoron is the maximum amount of current that
the Motoron can continuously provide to each motor. The continuous current per phase of
the Motoron M3S256 and M3 256 is 2.0 A.
• The rated voltage of a DC motor is the voltage at which the DC motor was designed to run.
You can apply voltages to the motor that are higher or lower than its rated voltage, but higher
voltages bring a risk of overheating the motor or reducing its lifetime.
• The no-load current of a DC motor is the current that the motor will draw if you apply the
rated voltage to the motor while its output is not connected to anything.
• The stall current of a DC motor is the current that the motor will draw if you apply the rated
voltage to the motor while forcing its output shaft to remain stationary.
There are guidelines you should be aware of when selecting the components of your system:
1. The voltage of your power supply should generally be greater than or equal to the rated
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 12 of 67

voltage of each DC motor. Otherwise, you will not get the full performance that the motor was
designed for. If your power supply’s voltage is much higher than the rated voltage of a DC
motor, you might account for that by using lower speeds for that motor in your commands to
the Motoron.
2. The voltage of your power supply should be within the operating voltage range of the
Motoron. Otherwise, the Motoron could malfunction or (in the case of high voltages) be
damaged.
3. The typical current draw you expect for each motor should be less than the Motoron’s
continuous current per motor. Each motor’s typical current draw will depend on your power
supply voltage, the speeds you command the motor to move, and the current ratings of
the motor. If a motor draws too much current for too long, there is a risk of triggering the
Motoron’s overcurrent or overtemperature faults, which shut down the motor.
4. The current limit of the power supply should be higher than the typical total current draw for
all the motors in your system. Furthermore, it is generally good for the current limit to be much
higher than that so your system can smoothly handle the times where the motors are drawing
more than the typical current, for example when they are accelerating or encountering extra
resistance.
3.2. Connecting everything
This section explains how to connect motor power, motors, and a microcontroller to a Motoron motor
controller.
Connecting terminal blocks
We generally recommend using green 3.5mm-pitch terminal blocks [https://www.pololu.com/product/
2444] for the motor power and motor connections. If you have an assembled version of the Motoron,
these terminal blocks come soldered to the board. Otherwise, you will need to solder them yourself.
They should be soldered to the larger through holes for board power and motor outputs (GND, VIN,
M1A, M1B, M2A, …).
Alternatively, if you are not going to stack multiple Motorons on top of each other, you can use blue
5mm-pitch terminal blocks [https://www.pololu.com/product/2440], which are included in the kit versions.
The 5mm-pitch terminal blocks are tall enough that it is easy to accidentally cause a short between
the motor outputs of two Motorons that are plugged into each other. If you decide to use the 5mm
terminal blocks, we recommend using the tabs on the side of the terminal blocks to connect them
together before soldering them to the Motoron (see our video about how to install terminal blocks
[https://www.youtube.com/watch?v=6pDyTLRZ2Eg] for more information).
Connecting motor power and motors
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 13 of 67

Motor power and motor connections for a Motoron M3S256 or M3H256 Triple Motor
Controller.
The negative terminal of the motor power supply should be connected to the Motoron’s large GND pin
or the smaller pins next to it. The positive terminal of the motor power supply should be connected
to the Motoron’s large VIN pin or the smaller pins next to it. These GND and VIN connections are
required for each Motoron in a stack of Motorons. Connecting two Motorons via stackable headers
does not connect their VIN pins at all, and it does not the connect their GND pins in a way that is
meant to carry the large currents involved in motor control. Note that connecting power to VIN does
not power the Motoron’s microcontroller and does not cause any LEDs to turn on.
Each motor should have one lead connected to an MxA pin (M1A, M2A, or M3A) and the other
lead connected to the MxB pin with the matching motor number. The Motoron’s concept of “forward”
corresponds to MxA driving high while MxB drives low, so you might consider this when deciding which
motor lead connects to which Motoron pin. You can also flip the wires later if you want to flip the
direction of motion.
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 14 of 67

Connecting a controller
Motoron M3S256 shield being
controlled by an Arduino Uno.
A Motoron M3H256 being controlled by
a Raspberry Pi.
The Motoron M3S256 shield is designed to be plugged into the 1×10 and 1×8 female headers of an
Arduino or Arduino-compatible board that has the shape of the Arduino Uno R3 [https://www.pololu.com/
product/2191] using stackable female headers or male headers soldered to the Motoron. Similarly, the
Motoron M3 256 is designed to be plugged into pins 1 through 20 of a Raspberry Pi using female
headers.
Plugging the Motoron into a controller this way connects the GND, SDA, and SCL pins of both
boards, allowing the controller to communicate with the Motoron via I²C. It also powers the Motoron’s
microcontroller by connecting the Arduino’s IOREF or the Raspberry Pi’s 3V3 pin to the Motoron’s
logic voltage.
The Motoron does not need to be connected directly to the controller: it can be connected through
another board (including other Motoron boards) as long as those boards pass the GND, SCL, SDA,
and logic voltage connections through.
You can also connect the Motoron to a controller board that has a different shape as long as you
make the same connections. The Motoron’s GND, SCL, and SDA pins should be connected to the
corresponding pins on the controller board, and the Motoron’s logic voltage (labeled IOREF or 3V3
depending on which type of Motoron you have) should be connected to the logic voltage supply of the
controller board, which should be between 2.8 V and 5.5 V.
Most of the pins on the Motoron have a spacing of 0.1" and are on the same 0.1" grid, making it easy
to connect the Motoron to a perf-board or breadboard.
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 15 of 67

A Raspberry Pi Pico on a breadboard
using a Motoron M3S256 shield to
control three motors.
An Arduino Micro on a breadboard
using a Motoron M3H256 to control
three motors.
After you have connected one Motoron to a microcontroller, you can connect other Motorons to the
same microcontroller simply by stacking them above or below the first one.
Once you make the GND and logic power connections and turn on the logic power, you should see
the Motoron’s yellow LED blink. The red LED will also turn on unless something is communicating with
the Motoron and causing it to turn the LED off.
Powering the controller
By default, the Motoron does not supply power to the Arduino or Raspberry Pi, so you will need to
power them separately. owever, there are options for powering the controllers, as documented in
Section 4 for the M3S256, and in Section 5 for the M3 256.
3.3. Enabling I²C on the Raspberry Pi
This section explains how to enable the correct I²C bus on your Raspberry Pi, make sure that your
user has permission to access it, and test your setup.
The Motoron is designed to connect to the I2C1 bus on the Raspberry Pi, which uses GPIO pin 2 for
SDA and GPIO pin 3 for SCL. If you are using Raspberry Pi OS, this bus is represented by /dev/
i2c-1 : that is the name of the device node that programs on your Raspberry Pi will open in order to
communicate with the Motoron or any other targets on the bus.
Try typing ls /dev/i2c* to list your system’s available I²C busses. If /dev/i2c-1 is not in the list then
you should run sudo raspi-config nonint do_i2c 0 to enable it. You must reboot your Raspberry Pi
for this change to take effect.
We recommend adding your user to the i2c group so you can access the Motoron and other I²C
devices without using sudo . Run the groups command to see what groups your user belongs to.
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 16 of 67

If i2c is not in the list, then you should add your user to it by running sudo usermod -a -G i2c
$(whoami) , logging out, and then logging in again.
After you have enabled I²C and connected your Motoron to your Raspberry Pi’s I²C bus, run i2cdetect
-y 1 . If everything is set up correctly, you should see output like this:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
This output means that the Raspberry Pi detected a device at address 16 (0x10 in hex), which is the
default I²C address used by the Motoron.
3.4. Setting I²C addresses with a Raspberry Pi
Each device on an I²C bus should have a unique address so that you can communicate with the device
without interfering with other devices on the bus. By default, the Motoron uses I²C address 16, so if
you have connected two or more Motorons to your bus, or you have another device that uses address
16, you will need to change the I²C addresses of one or more Motorons.
Warning: If you have devices on your I²C bus that are not Motorons, the procedure below
could cause undesired behavior when it sends commands to them that are intended for the
Motorons.
The recommended procedure for setting the I²C address of one or more Motorons that are connected
to the I²C bus of your Raspberry Pi is:
1. Ensure that the JMP1 pin on each Motoron is not connected to anything.
2. Download the Motoron Motor Controller Python library for Raspberry Pi [https://github.com/
pololu/motoron-rpi], and install its dependencies, as described in the “Getting started” section
of its README file.
3. In a Terminal, use cd to navigate into the directory holding the library and its examples.
4. Run ./set_i2c_addresses_example.py . This utility will print some information and then
prompt you for a command.
5. Perform a scan of the I²C bus by typing “s” followed by “Enter”. You should get output that
looks like this:
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 17 of 67

Scanning for I2C devices…
Found device at address 0
Found device at address 16
Done.
The scan detects that a device on the bus is responding to address 16 because that is
the Motoron’s default address. It also detects a device on address 0 because that is the
I²C general call address and all Motorons respond to it by default, in addition to the normal
address. We will use address 0 to send commands in later steps, so if the scan does not
detect any devices on address 0, those steps will probably fail.
6. Connect the JMP1 pin of one Motoron to GND. If you have not soldered headers to the
JMP1 pin and its adjacent GND pin, you can connect those two pins together using a wire,
test clip, or with a shorting block [https://www.pololu.com/product/968] attached to a 1×2 male
header [https://www.pololu.com/product/965]. Connecting JMP1 to GND is how we select which
Motoron’s address will be changed in the next step. Only one Motoron at a time should have
its JMP1 pin connected to GND.
7. Set the address of the selected Motoron by typing “a”, followed by the address (in decimal),
and then “Enter”. We recommend picking an address between 8 and 119 that is not in use
by any other devices on your bus (numbers outside that range could work too, but they are
reserved for other uses by the I²C specification). For example, type “a17” to set the address
of the Motoron to 17. Alternatively, you can just send “a” by itself in order to have the program
automatically pick an address for you, starting at 17 and skipping addresses that are already
in use on the bus.
This sends a “Write EEPROM” command to all of the Motorons using address 0, but the
command will only have an effect on the one Motoron whose JMP1 line is low. That Motoron
will record the address in its non-volatile EEPROM memory, but will not start using it yet.
8. Disconnect the JMP1 pin from GND.
9. Repeat the last three steps for every Motoron whose address you wish to change.
10. Type “r” to make the new addresses take effect. This sends a “Reset” command to all of the
Motorons using address 0. Alternatively, you can power cycle the system or use the RST pin
to reset the Motorons.
11. Perform another scan of the I²C bus by typing “s”. Check that a device is now found on each
of the addresses that you assigned.
3.5. Setting I²C addresses with an Arduino
Each device on an I²C bus should have a unique address so that you can communicate with the device
without interfering with other devices on the bus. By default, the Motoron uses I²C address 16, so if
you have connected two or more Motorons to your bus, or you have another device that uses address
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 18 of 67

16, you will need to change the I²C addresses of one or more Motorons.
Warning: If you have devices on your I²C bus that are not Motorons, the procedure below
could cause undesired behavior when it sends commands to them that are intended for the
Motorons.
The recommended procedure for setting the I²C address of one or more Motorons that are connected
to the I²C bus of your Arduino is:
1. Ensure that the JMP1 pin on each Motoron is not connected to anything.
2. Install the Motoron Arduino library [https://github.com/pololu/motoron-arduino] using the Arduino
library manager. You can open the Library Manager from the “Tools” menu by selecting
“Manage Libraries…”. If necessary, see the library’s README [https://github.com/pololu/
motoron-arduino] for more information about how to install it.
3. Upload the SetI2CAddresses example to your Arduino. If the Motoron library is installed
properly, you can find this example under Files > Examples > Motoron > SetI2CAddresses.
4. Open the Arduino IDE’s Serial Monitor, which you can find in the “Tools” menu.
5. Perform a scan of the I²C bus by typing “s” in the box at the top of the Serial Monitor and
clicking “Send”. You should get output that looks something like this:
Scanning for I2C devices…
Found device at address 0
Found device at address 16
Done.
The scan detects that a device on the bus is responding to address 16 because that is
the Motoron’s default address. It also detects a device on address 0 because that is the
I²C general call address and all Motorons respond to it by default, in addition to the normal
address. We will use address 0 to send commands in later steps, so if the scan does not
detect any devices on address 0, those steps will probably fail.
6. Connect the JMP1 pin of one Motoron to GND. If you have not soldered headers to the
JMP1 pin and its adjacent GND pin, you can connect those two pins together using a wire,
test clip, or with a shorting block [https://www.pololu.com/product/968] attached to a 1×2 male
header [https://www.pololu.com/product/965]. Connecting JMP1 to GND is how we select which
Motoron’s address will be changed in the next step. Only one Motoron at a time should have
its JMP1 pin connected to GND.
7. Set the address of the selected Motoron by typing “a” in the box at the top of the Serial
Monitor, followed by the address (in decimal), and clicking “Send”. We recommend picking
an address between 8 and 119 that is not in use by any other devices on your bus
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 19 of 67

(numbers outside that range could work too, but they are reserved for other uses by the I²C
specification). For example, type “a17” to set the address of the Motoron to 17. Alternatively,
you can just send “a” by itself in order to have the sketch automatically pick an address for
you, starting at 17 and skipping addresses that are already in use on the bus.
This sends a “Write EEPROM” command to all of the Motorons using address 0, but the
command will only have an effect on the one Motoron whose JMP1 line is low. That Motoron
will record the address in its non-volatile EEPROM memory, but will not start using it yet.
8. Disconnect the JMP1 pin from GND.
9. Repeat the last three steps for every Motoron whose address you wish to change.
10. Send “r” using the Serial Monitor to make the new addresses take effect. This sends a
“Reset” command to all of the Motorons using address 0. Alternatively, you can power cycle
the system or use the RST pin to reset the Motorons.
11. Perform another scan of the I²C bus by sending “s”. Check that a device is now found on
each of the addresses that you assigned.
3.6. Writing code
This section documents what you need to know to get started writing code to control the Motoron.
The Motoron’s I²C interface allows you to send commands to it and receive responses from it.
The commands are sequences of bytes (8-bit numbers from 0 to 255) and the responses are also
sequences of bytes. The details of how the I²C interface works are documented in Section 7. The
details of what commands are supported and how to encode them in bytes are documented in Section
3.6. Numbers prefixed with “0x” here are written in hexadecimal notation (base 16), and they are
written with their most significant digits first, just like regular decimal numbers.
Arduino library and examples
If you are controlling the Motoron from an Arduino or Arduino-compatible board, we recommend that
you install our Motoron Arduino library [https://github.com/pololu/motoron-arduino] and use one of the
examples that comes with it as a starting point for your code. The library comes with these beginner-
friendly examples, which you can find in the Arduino IDE under Files > Examples > Motoron.
•Simple: Shows how to control the Motoron in the simplest way.
•Careful: Shows how to shut down the motors whenever any problems are detected.
•Robust: Shows how to ignore or automatically recover from problems as much as possible.
Each of these examples just controls one Motoron. If you are using multiple Motorons, you can create
an additional MotoronI2C object for each controller, and pass the I²C address of each Motoron to the
Pololu Motoron Motor Controller User’s Guide © 2001–2022 Pololu Corporation
3. Getting started Page 20 of 67
This manual suits for next models
3
Table of contents
Other Pololu Corporation Microcontroller manuals
Popular Microcontroller manuals by other brands

ZiLOG
ZiLOG Z8 Encore! XP 4K Series user manual

Texas Instruments
Texas Instruments MSP430F67461 manual

NXP Semiconductors
NXP Semiconductors MRF300AN quick start guide

Atmel
Atmel SAM4L Xplained Pro user guide

Boreas Technologies
Boreas Technologies BOS1211 user guide

Texas Instruments
Texas Instruments TPS3703 manual

Cypress
Cypress PSOC CY8CKIT-146 quick start guide

Telit Wireless Solutions
Telit Wireless Solutions EVK4 user manual

Cypress MicroSystems
Cypress MicroSystems CY3215-DK Getting started guide

Fujitsu
Fujitsu F2MC-16LX Series Hardware manual

ST
ST UM0250 user manual

Texas Instruments
Texas Instruments REF70EVM user guide