Servo

Dependencies:   Servo TSI mbed

main.cpp

Committer:
facuramos
Date:
2015-08-26
Revision:
0:07bff9917d0d

File content as of revision 0:07bff9917d0d:

#include "mbed.h"
#include "TSISensor.h"
 
PwmOut servo(PTD5);
float t;
 
int main() {
    TSISensor tsi;
    while(true)
    {
     t=(tsi.readPercentage()*0.002);
    servo.period(0.020);      //Periodo=20 mS
    servo.pulsewidth(0.0005+t); //Hay que cambiar el ancho del pulso entre 1 y 2.5 mS para el Servo
    wait(0.02);
    
     
    }   
        }