hige dura
/
PWM_generator
PWM_generator
main.cpp
- Committer:
- higedura
- Date:
- 2012-12-05
- Revision:
- 1:1d1a7680a3fe
- Parent:
- 0:566768f53e4b
File content as of revision 1:1d1a7680a3fe:
#include "mbed.h" Serial pc(USBTX, USBRX); // tx, rx PwmOut esc(p22); int main() { int key_in = 0; double pulse_buf2 = 0; double pulse = 0; esc.period(0.018); esc.pulsewidth(0.001); while (1) { // ASCII henkan omazinai key_in = pc.getc()-48; //pc.printf("%d",key_in); //if(){ //pulse_buf ni value wo input //} // pulse no tasizan 0.001 ~ 0.002 //pulse = 0.001+0.0001*(double)pulse_buf; // limmiter if( pulse<0.001 ){ pulse = 0.001; } if( 0.0019<pulse ){ pulse = 0.0019; } // updating pulse width esc.pulsewidth(pulse); pc.printf("%f\r\n", pulse); } }