cuma coba publish ya

Dependencies:   mbed encoderKRAI

Committer:
315_josh
Date:
Thu Sep 12 09:25:41 2019 +0000
Revision:
0:cb94be0bdb13
ngetesdoang

Who changed what in which revision?

UserRevisionLine numberNew contents of line
315_josh 0:cb94be0bdb13 1 #include "mbed.h"
315_josh 0:cb94be0bdb13 2 #include "encoderKRAI.h"
315_josh 0:cb94be0bdb13 3
315_josh 0:cb94be0bdb13 4 Serial pc(USBTX, USBRX);
315_josh 0:cb94be0bdb13 5 double theta ;
315_josh 0:cb94be0bdb13 6 double pulse;
315_josh 0:cb94be0bdb13 7
315_josh 0:cb94be0bdb13 8 encoderKRAI enc_shagai(PC_6, PC_7, 538, encoderKRAI::X4_ENCODING);
315_josh 0:cb94be0bdb13 9
315_josh 0:cb94be0bdb13 10 void hitungParameter(){
315_josh 0:cb94be0bdb13 11 pulse=(double) enc_shagai.getPulses()*360/538;
315_josh 0:cb94be0bdb13 12 enc_shagai.reset();
315_josh 0:cb94be0bdb13 13 theta+=pulse;
315_josh 0:cb94be0bdb13 14 pc.printf("theta = %.2f\t\n", theta );
315_josh 0:cb94be0bdb13 15 }
315_josh 0:cb94be0bdb13 16
315_josh 0:cb94be0bdb13 17 int main (){
315_josh 0:cb94be0bdb13 18 while(1){
315_josh 0:cb94be0bdb13 19 hitungParameter();
315_josh 0:cb94be0bdb13 20 }
315_josh 0:cb94be0bdb13 21 }