Isaac Nolt
Published © GPL3+

How to Control a Servo with a Joystick

A simple step by step project explaining how to control a servo with a joystick.

BeginnerProtip1 hour12,682
How to Control a Servo with a Joystick

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Modulo Joystick
Modulo Joystick
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
it doesn't matter if you use a half size or not.
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

schematics

Code

servo control

C/C++
just copy the code onto the IDE an upload it to the board.
#include <Servo.h>

Servo myservo;

int potpin = 0;
int val;

void setup() {
  myservo.attach(7);
}

void loop() {
  val = analogRead(potpin);
  val = map(val, 0, 1023, 0, 180);
  myservo.write(val);
  delay(15);
}

Credits

Isaac Nolt

Isaac Nolt

5 projects • 3 followers
I'm at home and currently breathing. Check out my Youtube channel and subscribe at https://www.youtube.com/channel/UCRFGSJgj24tFT080VDW1hLw/
Thanks to Treebug842.

Comments