Project tutorial

Dual Axis Servo Control with Joystick © LGPL

Controlling two servos with a joystick (which was taken out from an old USB controller).

  • 2,740 views
  • 0 comments
  • 12 respects

Components and supplies

About this project

main aim or goal for building this project was to learn more about controlling servos with an joystick module and later use this setup to build an robotic arm or similar stuff.

I'm planning to attach an action camera to this setup.

anyways, watch the test video and subscribe to my YT channel. <3

Code

Untitled fileC/C++
#include <Servo.h>

Servo myservo1;  // create servo object to control a servo
Servo myservo2;
int potpin1 = A0;  // analog pin used to connect the potentiometer
int potpin2 = A1;
int val;    // variable to read the value from the analog pin

void setup() {
  myservo1.attach(9);
  myservo2.attach(10);// attaches the servo on pin 9 to the servo object
}

void loop() {
  val = analogRead(float(potpin1));            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo1.write(val);                  // sets the servo position according to the scaled value
  delay(15); // waits for the servo to get there

  val = analogRead(float(potpin2));            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo2.write(val);                  // sets the servo position according to the scaled value
  delay(15);

}

Schematics

untitled_sketch_bb_BASFraPpyQ.png
Untitled sketch bb basfrappyq

Comments

Similar projects you might like

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,591 views
  • 5 comments
  • 17 respects

Control Dual Axis FPV Camera Cradle with Joystick Module

Project tutorial by SurtrTech

  • 2,186 views
  • 4 comments
  • 21 respects

Arduino Joystick Servo Control Using 1Sheeld

Project tutorial by amrmostaafaa

  • 2,321 views
  • 0 comments
  • 12 respects

Line Follower Robot - PID Control - Android Setup

Project tutorial by MJRoBot

  • 28,428 views
  • 8 comments
  • 33 respects

Arduino Nano: Control 2 Stepper Motors With Joystick

Project tutorial by Boian Mitov

  • 11,875 views
  • 1 comment
  • 32 respects
Add projectSign up / Login