Pan Tilt with joystick

Last Updated on 10. October 2026 by SuffocationLink status: OK

Ich hatte einen Joystick, einen Arduino und einen Pan Tilt übrig und dachte mir, das könnte man doch mal kombinieren. Seht was dabei rausgekommen ist.

Facts

This is what I needed:

  • Analoger Joystick mit zwei Achsen
  • Arduino Uno or similar
  • Pan and tilt with two servos
  • Motorplatine V1 (praktisch, aber nicht nötig)
  • A few pin header female to female cables

Areas of application

  • Ferngesteuertes Schwenken und Neigen einer Kamera
  • pfff … weiss nicht … Teil eines Wurm- oder Schlangenroboters

Views

Programming

Libraries

No additional ones are required.

Test programme 1

Das Programm ist gänzlich einfach aufgebaut, es holt die Stellung des Joysticks und rechnet sie direkt, mit Hilfe des Map Befehls, in Servo Einstellungen um.

Source code PanTiltAndJoy.ino (GitHub GistLink status: OK)

/***********************************************
 * Control pan/tilt with joystick
 * www.fambach.net
 * GPL v2
 *
 * you can influence the drive of the servos by adjusting the min and max values.
 */
#include<Servo.h>


#define JOYX A0
#define JOYY A1
Servo servox;
Servo servoy;

void setup(){
  Serial.begin(115200);
  servox.attach(9);
  servoy.attach(10);
  
}

int xmin = 20, xmax = 130, ymin = 0, ymax = 125, step = 10; 
void loop(){

int ax = analogRead(JOYX);
int ay = analogRead(JOYY);
  int x = map(ax, 1024,0, xmin, xmax);
  int y = map(ay, 0,1024, ymin, ymax);

  servox.write(x);
  servoy.write(y);


  Serial.print("aX: ");
  Serial.print(ax);
  Serial.print(" aY: ");
  Serial.print(ay);

  Serial.print(" sX: ");
  Serial.print(x);
  Serial.print(" sY: ");
  Serial.print(y);

  Serial.println();

}

That's how it looks

https://photos.app.goo.gl/M9otS6fMsYdEp8yPA

Problems

Die Steuerung ist sehr ungenau, weil der Joystick sehr kurze Fahrwege hat. Evtl. gibt es hier bessere als die Chinaware.

Conclusion

The project was easier than expected and actually done with two lines of code.

Related Posts

Sources

Arduino – Pan/Tilt TestLink status: Unknown
Arduino Motor Shield V1Link status: OK
DateChangeAuthor
10.10.2026Gist-Einbettung durch Code-Block ersetzt (Gist als Quelle verlinkt)Suffocation
04.10.2026Rechtschreibung korrigiert: Tippfehler, Kommas, Groß-/KleinschreibungSuffocation
03.10.2026Log-Liste eingefügtSuffocation
30.06.2019Post createdSuffocation
Changelog

Leave a Reply

Your email address will not be published. Required fields are marked *