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
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
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
- Wire your DC motor to the Arduino
- Plug the Arduino board into your PC
- Check the COM ports to see if your Arduino is connected
- Upload the example code to the Arduino
- Open https://localhost:9515 in your browser
- Select the connection of your DC motor
- Set up the attributes of the DC motor
- 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
Prerequisites
- 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:
- Arduino Uno
- Ozeki DC Motor Driver
- Raspberry Pi
(If you use Raspberry Pi please jump to 'Step 3')
After wiring, please plug the board to your computer!
Step 2 - Upload code to the microcontroller
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 192.168.1.5, we would enter http://192.168.1.5:9513 into our webbrowser.
Step 5 - Understand the DC motors protocol
The DC Motor Controller can communicate with Ozeki through the following protocol.
References:
https://www.dummies.com
https://www.tutorialspoint.com
More information
- Arduino sensors and actuators
- How to use an analog sensor in arduino
- How to use a button controller in arduino
- How to use a buzzer in arduino
- How to use dc motors in arduino
- How to use a dht sensor in arduino
- How to use an EEPROM Manager in arduino
- How to use a gyroscope sensor in arduino
- How to use id manager in arduino
- How to use IR transceiver in arduino
- How to use an analog joystick in arduino
- How to use a keyboard in arduino
- How to use an LCD display in arduino
- How to use an NFC Reader in arduino
- How to use an optical gate in arduino
- How to use a register in arduino
- How to use an RF 433 MHz transceiver
- How to use an RF 2.4 GHz transceiver
- How to use an RGB LED in arduino
- How to use an RGB sensor in arduino
- How to use a rotary encoder in arduino
- How to use a servo motor in arduino
- How to use a stepper motor in arduino
- How to use a switch in arduino
- How to use a temperature sensor in arduino
- How to use a timer in arduino
- How to use an ultrasonic sensor in arduino