Boleh bisa langsung dicoba, tap servo base belum dikalibrasi

Dependencies:   mbed Servo

main.cpp

Committer:
D4n1elR
Date:
2019-05-11
Revision:
4:3db9524b9b63
Parent:
3:d1860dee0552
Child:
5:832f5a808578

File content as of revision 4:3db9524b9b63:

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

/* Nama servo
    4
    3
  21 22
    1 */
    
//PwmOut servo1(PB_7);
Servo servo1(PB_7);
Serial pc(USBTX,USBRX);

int main() {
    pc.baud(9600);
    pc.printf("test begin\n");
    
    //tes
    servo1.calibrate(0.001,120);
    //servo2.calibrate(0.001,150);
    float f=0;
    //servo2.write(1.0);
    while(1){
        servo1.position(f-62);
        //servo1.pulsewidth_ms(f);    //pc.printf("input (1..10) bakal dijadiin persen : ");
        pc.printf("input (1..360) bakal dijadiin derajat : ");
        pc.scanf("%f\n",&f);
        //pc.printf("\n");
//        float f = (float)n/(float)10;
        pc.printf("%f\n",&f);
        //pc.printf("\n");
        
    }
}