In Servo motor control using potentiometer tutorial, we’ll control servo motor Direction based on potentiometer movement. Potentiometer is connected on analog pin A0 of arduino uno. And servo motor is connected on pin number 9 of arduino. We are using PWM to control servo motor.
Materials required
- Arduino uno
- Potentiometer
- Servo motor
Circuit arrangement
Source Code :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* Code by satyam singh. ****** | |
//* subscribe my youtube channel from below link | |
//* https://www.youtube.com/channel/UCOrVJ1fDDCKDYMAYQmn6zWw | |
//* | |
//*************************************"**********************// | |
Servo servoa; | |
int potpin1 = 0; | |
int val1; | |
void setup() | |
{ | |
servoa.attach(9); | |
} | |
void loop() | |
{ | |
val1 = analogRead(potpin1); | |
val1 = map(val1, 0, 1023, 0, 179); | |
servoa.write(val1); | |
delay(15); | |
} |
0 Comments