Servo Motor Positioning-calibration How To Tutorial

About the project

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

Project info

Difficulty: Easy

Platforms: ArduinoVisuino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Arduino UNO Arduino UNO x 1
Breadboard (generic) Breadboard (generic) x 1
Jumper wires (generic) Jumper wires (generic) x 1
ElectroPeak 0.96" OLED 64x128 Display Module ElectroPeak 0.96" OLED 64x128 Display Module x 1
SG90 Micro-servo motor SG90 Micro-servo motor x 1

Software apps and online services

Visuino Visuino
Arduino IDE Arduino IDE

Story

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.

Step 1: What You Will Need

1 / 6

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

Step 2: The Circuit

  • 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]

Step 3: Start Visuino, and Select the Arduino UNO Board Type

1 / 2

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

Step 4: In Visuino Add Components

1 / 3

  • Add "Multiply Analog By Value" component
  • Add "SSD1306/SH1106 OLED Display (I2C)" component
  • Add "Servo" component

Step 5: In Visuino Set Components

1 / 6

  • 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

Step 6: In Visuino Connect Components

1 / 2

  • 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

Step 7: Generate, Compile, and Upload the Arduino Code

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.

Step 8: 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 tutorial, you can download it and open it in Visuino: https://www.visuino.eu

Schematics, diagrams and documents

Visuino File

Code

Visuino File

Credits

Photo of Ron

Ron

Arduino Developer

   

Leave your feedback...