el programa permite ingresar la posición en el eje X,Y,Z, haciendo que el Servo MG90S con sus movimientos de 180° trabaje en mm de 0 a 50.

Dependents:   PICCOLO_CNC PICCOLO_CNC1

Servo_X.h

Committer:
Stevenor1997
Date:
2018-02-20
Revision:
1:59dc95283a4d
Parent:
0:c5040669bd3e
Child:
2:cc30b42ac66f

File content as of revision 1:59dc95283a4d:

#include "mbed.h"

PwmOut mypwmX(PA_8);
PwmOut mypwmY(PB_10);
PwmOut mypwmZ(PB_4);
int Move_x,Move_y,Move_z;
class Servo
{
    private:
        int x,y,z;
    public:
        Servo();
        ~Servo();
        void SetServo(int,int,int);
        int GetServoX();
        int GetServoY();
        int GetServoZ();
};

Servo::Servo()
{
}
Servo::~Servo(){
}
void Servo::SetServo(int _x,int _y,int _z)
{
    x=_x;
    y=_y;
    z=_z;
    Move_x=(x*20)+1000;
    Move_y=(y*20)+1000;
    Move_z=(z*20)+1000;
    mypwmX.pulsewidth_us(Move_x);
    mypwmY.pulsewidth_us(Move_y);
    mypwmZ.pulsewidth_us(Move_z);   
}
int Servo::GetServoX()
{
    return x;
}
int Servo::GetServoY()
{
    return y;
}
int Servo::GetServoZ()
{
    return y;
}