Not much different from DC motor speed control program with potentiometer, this time we will controlling angle of rotation on servo motor using potentiometer.
The Arduino UNO reads the analog data from the change in the output voltage of the meter, the result of the data reading used to determine the PWM value connected to the servo motor input so that the servo motor rotates according to its PWM value.
Hardware Requirement
- Potentiometer 50K
- Motor Servo
- Power supply +5 Volt
- Jumper
Block Diagram
Schematic
Arduino - Motor Servo Wiring
Arduino - Potentiometer Wiring
Source Code/Sketch
#include <Servo.h>
Servo myservo;
void setup(){
//servo pada pin 10
myservo.attach(10);
}
void loop(){
//potensio meter pin A1
int val = analogRead(A1);
val = map(val, 0, 1023, 0, 180);
myservo.write(val);
}
Servo myservo;
void setup(){
//servo pada pin 10
myservo.attach(10);
}
void loop(){
//potensio meter pin A1
int val = analogRead(A1);
val = map(val, 0, 1023, 0, 180);
myservo.write(val);
}
How it Works
1. Connect the Arduino with Peripherals needed
2. Plug in the Power Source on the device
3. Compile and upload the script program above to your arduino
4. Please rotate your potential meter so that the servo motor rotates according to the PWM value
Video for Project V- 23. Motor Servo Speed Control using Potensio Meter (Arduino Based)
Required File
No comments:
Post a Comment