SERVO MOTOR WITH ARDUINO

 





Components required:-
1. Arduino Uno:-


2. Servo Motor:-






SERVO MOTOR- It can be set to any precise angle. The servo motor has an output shaft which can be positioned in any angular position by sending a coded signal. The motor operates until it reaches to its desired angle , as soon as it reaches to its desired angle it gets stopped. Servo motor requires PWM signal to function. 

          SERVO MOTOR PINOUT

1. GND PIN- connected to GND pin of Arduino.

2. INPUT– here we have to provide signal to set servo.

 3. VCC PIN-  connected to VCC pin of Arduino


SERVO MOTOR INTERFACING WITH ARDUINO

1. Connect VCC of servo motor to 5v pin of Arduino.

2. Connect GND pin of servo motor to GND pin of Arduino

3. Connect SIGNAL pin of servo motor to pin 2 of Arduino.



    ARDUINO CODE

_______________________________________________

#include <Servo.h>

int angle;

Servo servo;

void setup() {

  servo.attach(2);

  Serial.begin(9600);

  Serial.println("At what angle servo should set?");

}

 

void loop()

{

  if (Serial.available() > 0)

  {

    angle = Serial.parseInt();

    servo.write(angle);

    Serial.print("Servo is set to ");

    Serial.print(angle);

    Serial.println(" degree");

    delay(10);

  }

}

________________________________________

To understand this project in detail, click here or on this image to watch on YouTube.





Comments