Ozeki 10
Rotary Encoder Rotary Encoder | Arduino Mega Arduino Mega

How to use an Arduino servo motor

In the following guide you will be able to learn about servo motors. First, you can read about the basic concept behind how servo motors work, and hou you can connect them to your Arduino. Then, in a step by step guide you will get an introduction to how the servo motors can be controlled from a computer with Ozeki 10. So, let's get started right now.

What is a servo motor?

A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity and acceleration. It consists of a suitable motor coupled to a sensor for position feedback. It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servomotors.

How does a servo motor works?

Servos have integrated gears and a shaft that can be precisely controlled. Standard servos allow the shaft to be positioned at various angles, usually between 0 and 180 degrees. Continuous rotation servos allow the rotation of the shaft to be set to various speeds.

How to use an Arduino servo motor?

Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board. Note that servos draw considerable power, so if you need to drive more than one or two, you'll probably need to power them from a separate supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together.

Arduino servo motor wiring diagram

wiring diagram of arduino servo motor
Figure 1 - Wiring diagram of Arduino Servo Motor

How to use an Arduino servo motor in Ozeki

Servo Controller connection transfers commands to your servo motors from any selected Ozeki connection. This guarantees that all servo motors precisely turn to the angle specified in the commands. Each command can seperately move the motors. To use the Servo 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 Servo 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 Servo Motor code to Arduino Uno
Upload the Servo Motor code to Arduino Mega 2560
Upload the Servo Motor code to Arduino Nano
Upload the Servo Motor code to Ozeki Matrix

The arduino motors and Ozeki will communicate over the USB port using the Ozeki Servo 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 Servo 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 the Servo motor to your Arduino
  2. Connect the Arduino board into your computer
  3. Check the COM ports to make sure your Arduino is connected
  4. Open the Arduino application on your computer
  5. Upload example code to the Arduino
  6. Open Ozeki 10 GUI in your browser
  7. Choose the connection of the Servo motor
  8. Test the Servo motor by setting the degree and speed

System overview

The system we suggest consits of a servo 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

setup servo motors to pc using arduino
Figure 2 - System configuration of servo motor connecting to PC using Arduino

Prerequisites

  • 1 to 6 servo motors (e.g. SG90, MG996R or SM-S8330M)
  • Ozeki 10 installed on your computer
  • Programmable board (Arduino Mega/Nano/Uno or Ozeki Servo Module)
  • USB cable is needed between the board and your computer

Step 1 - Wire the servo motor to your Arduino

You can see how to wire the servo 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 servo motor

Step 4 - Configure the servo motor in Ozeki 10

To configure your keyboard (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 servo motor protocol

The Servo Controller can communicate with Ozeki through the following protocol.

References:
https://en.wikipedia.org
https://www.arduino.cc

Copyright © 2000- - Ozeki Ltd | info@ozeki.hu
Home > Products > Ozeki 10 > Connections > Arduino > Servo Motors
Legal | Privacy | Terms of use | 3034
18.204.229.70 | 92.118.27.157 | Login