Uploaded by Unknown

Arduino Servo Motor Control Lab Report

advertisement
Rushikesh Chaudhari​
202251113
Part 1 : Basic Servo Motor Control using Arduino IDE
Objective
To understand and implement the fundamental control of a servo motor using
an Arduino board. The goal is to make the servo motor rotate to specific
angles—0°, 90°, and 180°—in a loop using code uploaded from the Arduino IDE.
Components Required:
● ESP8266 nodemcu board
● Servo motor(MG90S)
● Jumper wires
● USB cable for uploading the code
● Breadboard
Circuit Connections
●​ Connect the red wire (VCC) of the servo to the 5V pin on the Arduino.
●​ Connect the brown/black wire (GND) of the servo to the GND pin on the
Arduino.
●​ Connect the yellow/white wire (Signal) of the servo to digital pin 9 on the
Arduino.​
This setup allows the Arduino to send PWM signals to control the servo motor's
position
Arduino Code:
Output In Serial Monitor :
Conclusion :
The servo motor successfully rotates to three distinct positions in a loop:
●​ 0° (leftmost position)
●​ 90° (center position)
●​ 180° (rightmost position)​
Each position is held for 1 second before moving to the next, demonstrating
basic position control using Arduino code. This confirms that the servo responds
correctly to PWM signals sent from the Arduino.
Part 2: Creating a Servo Control with Angle Selection
Objective
To create an interactive system where a potentiometer is used to manually
control the angle of a servo motor. The servo responds in real-time to changes in
the potentiometer's position, allowing angle selection between 0° and 180°.
Components Required:
●​
●​
●​
●​
●​
●​
Arduino Uno board
Micro servo motor (MG90S / SG90)
Potentiometer
Jumper wires
USB cable for uploading code
Breadboard
Circuit Connections
●​ Connect the red wire (VCC) of the servo to the 5V pin on the Arduino.
●​ Connect the brown/black wire (GND) of the servo to the GND pin on the
Arduino.
●​ Connect the yellow/white wire (Signal) of the servo to digital pin 9 on the
Arduino.
●​ Connect one outer pin of the potentiometer to 5V.
●​ Connect the other outer pin of the potentiometer to GND.
●​ Connect the middle pin of the potentiometer to analog pin A0 on the
Arduino.​
This setup allows the potentiometer to act as an analog input device, controlling
the angle of the servo motor through mapped values.
●​ 60 degree Angle
●​
90 degree Angle
●​ 120 degree Angle
●​ 180 Degree Angle
​
Conclusion:
This part of the experiment successfully demonstrates how a servo motor's
position can be dynamically controlled using a potentiometer as an input
device.
●​ The servo motor responded accurately to changes in the potentiometer
position.
●​ Real-time feedback was observed in the serial monitor.
●​ This implementation simulates interactive angle control systems used in
various real-world applications such as robotic arms, analog gauges, and
precision controls.
Part 3 : Controlling a Servo Motor Over WiFi
Objective
The aim of this experiment is to control a servo motor remotely over WiFi using
the ESP32 microcontroller. The experiment demonstrates both basic servo motor
control and an advanced application — a speedometer simulation — through
web-based interaction.
Simulation Platforms Used
●​ Wokwi: Utilized for simulating WiFi-enabled projects due to its support for
ESP32 and networking features.
●​ Tinkercad: Initially used for Arduino-based servo control, but it lacks
support for WiFi-based ESP32 simulations.
Hardware & Components
●​
●​
●​
●​
●​
ESP32 Development Board
Servo Motor (SG90 or similar)
Breadboard and jumper wires
Potentiometers (2 units)
Power Source (via USB or battery if using real hardware)
Experiment Setup
Servo Motor Wiring
●​ Signal (Orange/Yellow) → GPIO D5 (ESP32 Pin GPIO14)
●​ VCC (Red) → 3.3V
●​ GND (Brown/Black) → GND
Code Files and Their Roles
1. Sarvo.ino –Main ESP32 Program
The core program running on the ESP32. Functions include:
●​
●​
●​
●​
Connecting to WiFi
Running a local web server
Handling HTTP requests from a browser interface
Controlling the servo angle based on user input from the web UI
​
2. Index.h — Web Interface (HTML + JavaScript)
●​ Contains HTML + JavaScript code for a circular dial interface.
●​ The dial UI allows real-time servo angle control through the browser.
●​ Embedded in main.ino using #include "index.h".
●​ .wokwi-lib.json file — Dependency Declaration
Output
Once the ESP32 successfully connects to the WiFi network (Wokwi-GUEST in this
case), it will print a message in the Serial Monitor, including:
●​ Connection Status - Successful we can see IP Address Clearly
​
Download