How to use Arduino DC motors

In this guide, you will be able to get some information about the Arduino DC motors. The DC motor is the most basic of electric motors and is used in all types of hobby electronics. This guide provides you some basic information about the DC motors, how you can connect it to your Arduino, and how you can use it with Ozeki 10. The document also includes diagrams and videos to help you to understand the concept behind DC motors. So, let's get started.

What is an Arduino DC motor?

A DC motor (Direct Current motor) is the most common type of motor. DC motors normally have just two leads, one positive and one negative. If you connect these two leads directly to a battery, the motor will rotate. If you switch the leads, the motor will rotate in the opposite direction.

How to use an Arduino DC motor?

To operate with DC motors, you need to connect three pins as the wiring diagram shows it (Figure 1). One needs to be connected to the ground (Gnd), the other from the motor to the 5V pin. The third pins have to be connected to the PWM pin on your Arduino. With the connected DC motor, now you will be able to control it. You can adjust the rotation speed of the motor between the range of 0 and 255.

Arduino DC motor wiring diagram

wiring diagram of arduino dc motors
Figure 1 - Wiring diagram of Arduino DC motors

How to use Arduino DC motors in Ozeki

DC motor controller connects your DC motors to your Ozeki software. You can move up to two DC motors through any L298N motor driver chip. This chip is integrated in the LM298 DC Motor Controller Board and also in the Ozeki DC Motor Driver. You can change motor movement direction and speed for both motors by using Ozeki. The motors should be powered from an outside power source with maximum of 36V. To use the DC motor in Ozeki, you first need to download Ozeki Robot Developer. Ozeki Robot Developer will install the Arduino libraries needed to use this sensor efficiently.

Download Ozeki Robot Developer

Download Ozeki Robot Developer

After Ozeki Robot developer is installed, you need to upload the DC motor control code to your Arduino. You can find the code and download instructions on the following pages. The upload process includes two steps: first you need to format the EEPROM of the arduino, then you need to upload the control code. The procedure is very simple, it only takes a few seconds.

Upload the DC motor code to Arduino Uno
Upload the DC motor code to Arduino Mega 2560
Upload the DC motor code to Arduino Nano
Upload the DC motor code to Ozeki Matrix
Upload the DC motor code to Raspberry Pi

The arduino motors and Ozeki will communicate over the USB port using the Ozeki DC motor protocol. This protocol makes it possible for you to use the motor directly on your PC. You will be able to control this motor through the web based user interface or you will be able to communicate with it using Ozeki Chat. You can read more about chat control on the following page.

How to communicate with the DC motor using chat

It is important to understand chat control, because when you build a robot, the way you wish to control this motor is by sending and receiving messages. If you open the Ozeki Robot Developer app, you will see, who you can write a C#.Net program to work with this motor.

Connection steps

  1. Wire your DC motor to the Arduino
  2. Plug the Arduino board into your PC
  3. Check the COM ports to see if your Arduino is connected
  4. Upload the example code to the Arduino
  5. Open https://localhost:9515 in your browser
  6. Select the connection of your DC motor
  7. Set up the attributes of the DC motor
  8. Click 'Update' to test your DC motor

System overview

The system we suggest consits of a DC motor, that is wired to the analog port of your Arduino. The Arduino will be responsible for reading data from this device in real-time. The brain of the system will be running on a PC (Figure 2). On the PC, Ozeki 10 will be able to manage the communication. You can easily run Ozeki 10 using a webbrowser

system configuration of dc motort connecting to pc using arduino
Figure 2 - System configuration of DC motor connecting to PC using Arduino


  • 1 or 2 small DC motor
  • Ozeki 10 installed on your computer
  • Programmable board (Arduino Mega/Nano/Uno, Ozeki DC Motor Driver or Raspberry Pi)
  • If you do not use an Ozeki DC Motor Driver than an LM298 DC Motor controller board is required
  • USB cable is needed between Arduino Mega/Nano/Uno, Ozeki DC Motor Driver and your computer

Step 1 - Wire the DC motors to your Arduino

You can see how to wire the DC motors to any of the following boards:

After wiring, please plug the board to your computer!

Step 2 - Upload code to the microcontroller

(Here is the code to upload)

Step 3 - Start Ozeki 10 to try the DC motors

Step 4 - Configure your DC motors in Ozeki 10

To be able to configure your DC motors (attached to your Arduino) in Ozeki 10, that is installed on your computer, you need to open the graphical user interface (GUI) of Ozeki 10. You can open the GUI by entering the URL of the computer into your webbrowser. For example, if our PC has an IP address of, we would enter into our webbrowser.

Step 5 - Understand the DC motors protocol

The DC Motor Controller can communicate with Ozeki through the following protocol.


More information