Project showcase
How to  Control Single Servo Motor by Joystick

How to Control Single Servo Motor by Joystick © LGPL

Mabuhay! Darwin here. In this project, I will teach you how to control a servo motor using a joystick module.

  • 9,954 views
  • 6 comments
  • 14 respects

Components and supplies

Apps and online services

About this project

This is the easiest way to control a servo motor by a joystick module. Some tutorials require a breadboard and a motor shield, but in this tutorial only basic tools are needed and we will not needing other peripherals.

If you like to see this project working, Click the video below.

_____________________________________________________________

NOTE! To be updated for my future projects and have inquires. Please contact me thru this following social media account.

Subscribe to my Youtube channel here  
https://www.youtube.com/channel/UCHDgqVphwxcUjYaRZheDfpw
 
Like my Facebook  
https://www.facebook.com/darwindelacruzofficial/ 
 
Follow me on twitter 
https://twitter.com/dardelacruz 

_____________________________________________________________

Instruction:

Wiring the Joy Stick Module to the Arduino

GND connect to Pin A3

+5v connect to Pin A2

VRx connect to Pin A1

VRy connect to Pin A0

(SW can be connected to a digital pin and used as a switch)

Servo Motor

Orange connect to Pin 9

Red connect to Pin 5v

Brown connect to Pin GND (either one is Good)

Note! The orange wire connects to the far side of the Arduino board.

Code

Untitled fileArduino
#include <Servo.h>
#define SERVO_PIN 9
#define GROUND_JOY_PIN A3            //joystick ground pin will connect to Arduino analog pin A3
#define VOUT_JOY_PIN A2              //joystick +5 V pin will connect to Arduino analog pin A2
#define XJOY_PIN A1                  //X axis reading from joystick will go into analog pin A1
Servo myservo ;
 
void setup()
{
 Serial.begin(9600);
 pinMode(VOUT_JOY_PIN, OUTPUT) ;    //pin A3 shall be used as output
 pinMode(GROUND_JOY_PIN, OUTPUT) ;  //pin A2 shall be used as output
 digitalWrite(VOUT_JOY_PIN, HIGH) ; //set pin A3 to high (+5V)
 digitalWrite(GROUND_JOY_PIN,LOW) ; //set pin A3 to low (ground)
 myservo.attach(9);
}
 
void loop()
{
 delay(200);                    
 int joystickXVal = analogRead(XJOY_PIN) ;  //read joystick input on pin A1
 Serial.print(joystickXVal);                //print the value from A1
 Serial.println(" = input from joystick");  //print "=input from joystick" next to the value
 Serial.print((joystickXVal+520)/10);       //print a from A1 calculated, scaled value
 Serial.println(" = output to servo");      //print "=output to servo" next to the value
 Serial.println() ;
 myservo.write((joystickXVal+520)/10);      //write the calculated value to the servo  
}

Schematics

aa_LQB2f2Ad3R.png
Aa lqb2f2ad3r

Comments

Similar projects you might like

Servo Control with TV Remote Control

Project showcase by eldo85

  • 7,822 views
  • 5 comments
  • 23 respects

Using Serial Monitor to Control Servo Motor

Project tutorial by Kub_Luk

  • 4,978 views
  • 10 comments
  • 32 respects

Arduino/Android - BLUETOOTH Multi Servo Motor Control

Project tutorial by Danny van den Brande

  • 14,387 views
  • 8 comments
  • 23 respects

Temperature Sensor To control Servo Motor

by Jasleen

  • 8,647 views
  • 2 comments
  • 12 respects

Control Servo Power with a Transistor

Project showcase by Kevin Gagnon

  • 6,104 views
  • 1 comment
  • 9 respects
Add projectSign up / Login