In this Project, we will see about how to interface Servo Motor with Arduino.
Circuit Diagram:
Arduino Code:
servo_knob_code.ino
#include <Servo.h> Servo myservo; int potpin = 0; int val; void setup() { myservo.attach(9); } void loop() { val = analogRead(potpin); val = map(val, 0, 1023, 0, 180); myservo.write(val); delay(15); }
servo_90_code.ino
#include <Servo.h> Servo myservo; void setup() { myservo.attach(9); } void loop() { myservo.write(0); delay(1000); myservo.write(90); delay(1000); }
servo_sweep_code.ino
#include <Servo.h> Servo myservo; int pos = 0; void setup() { myservo.attach(9); } void loop() { for (pos = 0; pos <= 180; pos += 1) { myservo.write(pos); delay(15); } for (pos = 180; pos >= 0; pos -= 1) { myservo.write(pos); delay(15); } }
Youtube Video Tutorial:
Download our official Android App in PlayStore. Click Here
You can get the all the required files (like Circuit Diagram, Arduino.ino file, Libraries Used, and others) for the project in ZIP format and much more...
No comments:
Post a Comment