Servo Motor Interfacing with ARM mbed

Overview of Servo Motor

Servo Motor

 

  • A servo motor is an electric device used for precise control of angular rotation. It is used in applications that demand precise control over motion, like in case of control of robotic arm.
  • The rotation angle of the servo motor is controlled by applying a PWM signal to it.
  • By varying the width of the PWM signal, we can change the rotation angle and direction of the motor.

For more information about Servo Motor and how to use it, refer the topic Servo Motor in the sensors and modules section.

 

Connection Diagram of Servo Motor with ARM MBED (LPC1768)

Interfacing Servo Motor With ARM MBED

 

Rotate Servo Motor using LPC1768 ARM MBED

Here, we will be using Simon Ford‘sServo” Library from MBED.

Download or Import code from here.

Here is the program to drive the servo motor for 0-180 degree and 180-0.

 

Servo Motor Code for LPC1768 ARM MBED

#include "mbed.h"
#include "Servo.h"

Servo myservo(p21);

int main()
{
    while(1) {
        for(int i=0; i<100; i++) {
            myservo = i/100.0;
            wait(0.01);
        }
        for(int i=100; i>0; i--) {
            myservo = i/100.0;
            wait(0.01);
        }
    }
}

Components Used

ARM mbed 1768 LPC1768 Board
ARM mbed 1768 Board
1
Servo Motor MG995
Servo Motor MG995
1

Downloads

Servo_mbed_uvision5_lpc1768 Download
Ad