Servo motor controlled by Joystick using Arduino - Wired Connection
Circuit Diagram:
Required Components:
Arduino uno/nano - 1 Nos
Battery - 1 Nos
Servo Motor - 1 Nos
Joystick - 1 Nos
Program Code:
#include <Servo.h>
Servo servo1;
Servo servo2;
int joyX = A1;
int joyY = A2;
int servoVal;
void setup()
{
servo1.attach(6);
servo2.attach(5);
}
void loop()
{
servoVal = analogRead(joyX);
servoVal = map(servoVal, 0, 1023, 5, 175); // To reduce Buzz effect adjust range form (0-180) to (5-175)
servo1.write(servoVal);
servoVal = analogRead(joyY);
servoVal = map(servoVal, 0, 1023, 5, 175); // To reduce Buzz effect adjust range form (0-180) to (5-175)
servo2.write(servoVal);
delay(15);
}
Video:
Comments
Post a Comment