To make a servo motor move using a joystick and Arduino Nano, follow these steps:
Components Required
- Arduino Nano
- Servo Motor (e.g., SG90 or MG996R)
- Joystick Module
- Jumper Wires
- Breadboard
- Power Source (USB or 5V external power)
Connections
Joystick Module:
- VCC → 5V of Arduino Nano
- GND → GND of Arduino Nano
- VRx (Horizontal) → A0 of Arduino Nano
- VRy (Vertical) → A1 of Arduino Nano (Optional if only one axis is needed)
Servo Motor:
- Signal → D9 of Arduino Nano
- VCC → External 5V power supply (if needed, depending on servo's power requirements)
- GND → Common ground with Arduino Nano and joystick
Circuit Diagram
Video Link: - Click Here For Video
How To Control a Servo Motor using Joystick DIY Project by WTC Zone simple Circuit: -
How To Control a Servo Motor using Joystick DIY Project by WTC Zone Arduino Programming: -
Arduino IDE Program
Code for Controlling a Servo Motor using Joystick DIY Project by WTC Zone
#include <Servo.h>
// Create a Servo objectServo myServo;
// Define joystick input pinconst int joystickPin = A0;
// Define the servo control pinconst int servoPin = 9;
void setup() { // Attach the servo to the defined pin myServo.attach(servoPin);
// Start serial communication for debugging Serial.begin(9600);}
void loop() { // Read the joystick value (0-1023) int joystickValue = analogRead(joystickPin);
// Map the joystick value to the servo's angle range (0-180) int servoAngle = map(joystickValue, 0, 1023, 0, 180);
// Move the servo to the mapped angle myServo.write(servoAngle);
// Print the values for debugging Serial.print("Joystick Value: "); Serial.print(joystickValue); Serial.print(" | Servo Angle: "); Serial.println(servoAngle);
// Small delay for stability delay(15);}
-----------------------------------------------------------------------------------------------------------------
Share, Support, and Subscribe!!! 1. PRO KAM EXPLAINED 2. Knowledge KAM 3. PRO KAM Follow us on 1. Facebook 2. Instagram 3. Pinterest 4. Blogspot 5 Twitter If you have any other ideas to make me design, you can describe them in the comment section and if I can, I will make a designing video on it. So I am waiting #prokam #wtc #Arduino #ideas #projects #diy #how #to #ArduinoProjects #UltrasonicSensor #HeightMeasurement #TechDIY #WeTechCreators #wtczo
0 Comments