Servo Motor Positioning-calibration How to Tutorial

by RonFrtek in Circuits > Arduino

5861 Views, 3 Favorites, 0 Comments

Servo Motor Positioning-calibration How to Tutorial

Servo Motor Positioning-calibration How to Tutorial

In this tutorial we will learn how to position or calibrate a servo motor, this is often useful in robotics where we need to center a servo motor to a certain position before mounting it.

We will display an analog value from the potentiometer and servo degrees on the OLED Display.

Watch the video.

What You Will Need

FZJ1USDK26CLY4O (1).jpg
FMT2X9VKEY93G5P.jpg
pctdetail.775-114.1.jpg
oled.png
FZEK4WBK3XGYAP0.LARGE.jpg
VisuinoAdvrtisementVersion8.jpg
FMMM5N5KEY93G5M.jpg

  • Servo motor
  • Potentiometer
  • OLED Display
  • Jumper wires
  • Breadboard
  • Arduino Uno or any other Arduino board
  • Visuino software: Download here

The Circuit

2020-12-06_21-29-42.jpg
  • Connect Servo motor "Orange" (signal) pin to Arduino Digital pin[7]
  • Connect Servo motor "Red" pin to Arduino positive pin[5V]
  • Connect Servo motor "Brown" pin to Arduino negative pin[GND]
  • Connect potentiometer pin [DTA] to arduino analog pin [A0]
  • Connect potentiometer pin [VCC] to arduino pin [5V]
  • Connect potentiometer pin [GND] to arduino pin [GND]
  • Connect OLED Display pin[VCC] to Arduino pin[5V]
  • Connect OLED Display pin[GND] to Arduino pin[GND]
  • Connect OLED Display pin[SDA] to Arduino pin[SDA]
  • Connect OLED Display pin[SCL] to Arduino pin[SCL]

Start Visuino, and Select the Arduino UNO Board Type

FRWQB80K1RVKKV9.LARGE.jpg
F311FBVK5AHN5HJ.LARGE.jpg

The Visuino: https://www.visuino.eu also needs to be installed. Download Free version or register for a Free Trial.

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add Components

2020-12-07_14-24-47.jpg
2020-12-07_1-27-24.jpg
2020-12-07_14-26-45.jpg
  • Add "Multiply Analog By Value" component
  • Add "SSD1306/SH1106 OLED Display (I2C)" component
  • Add "Servo" component

In Visuino Set Components

2020-12-07_14-56-31.jpg
2020-12-07_14-56-19.jpg
2020-12-07_14-56-05.jpg
2020-12-07_14-55-23.jpg
2020-12-07_14-28-55.jpg
2020-12-07_14-28-35.jpg
  • Select "MultiplyByValue1" and in the properties set Value to 180

Double click on the "DisplayOLED1" and in the Elements Window:

  • drag "Draw Text" to the left side and in the properties window set size to 2 and text to SERVO
  • drag "Draw Text" to the left side and in the properties window set Y to 20 and text to Degree:
  • drag "Text Field" to the left side and in the properties window set size to 2 X to 40 and Y to 20
  • drag "Draw Text" to the left side and in the properties window set text to Value: and Y to 40
  • drag "Text Field" to the left side and in the properties window set size to 2 X to 40 and Y to 40

Close the Elements window

In Visuino Connect Components

2020-12-07_16-43-38.jpg
servo-calibrate.png
  • Connect Arduino Analog pin 0 Out to MultiplyByValue1 pin In
  • Connect Arduino Analog pin 0 Out to Servo1 pin In
  • Connect Arduino Analog pin 0 Out to DisplayOLED1 > Text Field2 pin In
  • Connect MultiplyByValue1 pin Out to DisplayOLED1 > Text Field1 pin In
  • Connect Servo1 pin Out to Arduino digital pin 7
  • Connect DisplayOLED1 pin I2C Out to Arduino I2C In

Generate, Compile, and Upload the Arduino Code

2020-10-30_13-20-50.jpg

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play

If you power the Arduino UNO module, and slide a potentiometer the servo motor will spin and on the OLED display you will be able to see degrees and a potentiometer analog Value.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it and open it in Visuino: https://www.visuino.eu