vuelatech_indonesia
Published

Controlling Servo Using Joystick

Move it and joy it

IntermediateFull instructions provided2,117
Controlling Servo Using Joystick

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Modulo Joystick
Modulo Joystick
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver
Optional, This tool is used to screw the servo up with its propeller

Story

Read more

Schematics

Circuit diagram

This is the circuit

Code

Joystick control servo code

HTML
Code for the all parts of this project.
#include <Servo.h>

//Include the servo library

Servo servo1;
Servo servo2;

int joyX =0;
int joyY =1;


int joyVal;

void setup()
{ //attaches our servos on pins PWM 3-5
  servo1.attach(3);
  servo2.attach(5);
}

void loop()
{
  //read the value of joystick (between 0-1023)
  joyVal = analogRead(joyX);
  joyVal = map (joyVal, 0, 1023, 0, 180); //servo value between 0-180
  servo1.write(joyVal); //set the servo position according to the joystick value

  joyVal = analogRead(joyY);
  joyVal = map (joyVal, 0, 1023, 0, 180);
  servo2.write(joyVal);
  delay(15);
}G

Credits

vuelatech_indonesia
1 project • 0 followers

Comments