Introduction: Joystick Controlled Servo Using Arduino(with Programming)
In this tutorial we will make a joystick control servo using Arduino Uno.Servo will move according to joystick motion.
Step 1: Components Required:
- Arduino Uno
- Joystick
- Servo motor
- Breadboard
- wires
Step 2: Connection:
Connect the all components according to circuit diagram:
- Joystick Connection:
- joystick VCC --> Arduino 5V
- joystick GND --> Arduino GND
- joystick x_axis --> Arduino pin A0
- Servo Connection:
- servo VCC --> Arduino 5V
- servo GND --> Arduino GND
- Servo data_pins --> Arduino pin 10
Step 3: Programming:
Upload the following program in Arduino Uno board:
#include<Servo.h>
Servo servo;
int x_axis;
int servo_val;
void setup()
{
pinMode(A0,INPUT);
servo.attach(10);
}
void loop()
{
x_axis=analogRead(A0);
servo_val=map(x_axis,0,1023,0,180);
servo.write(servo_val);
}
Step 4: Source Code:
code :Source code(click here)