諒太 宮澤
/
motor_test
単輪試験機用モータドライバテスト
main.cpp
- Committer:
- manimani3712
- Date:
- 2016-01-12
- Revision:
- 0:f577792e4c6c
File content as of revision 0:f577792e4c6c:
//motor_test #include "mbed.h" DigitalOut rled(LED_RED); DigitalOut gled(LED_GREEN); DigitalOut bled(LED_BLUE); Serial pc(USBTX, USBRX); PwmOut motor(PTC9); int s; BusOut motor1(PTA13,PTD5); void drivecommand () { s = pc.getc(); pc.printf("%c",s); if(s=='1'){ motor1 = 3; float pwidth; motor.period_ms(10); motor.pulsewidth(pwidth); pc.printf("slow\n"); motor1 = 1; } else if(s=='2'){ motor1 = 3; float pwidth; motor.period_ms(20); motor.pulsewidth(pwidth); pc.printf("normal\n"); motor1 = 2; } else if(s=='3'){ motor1 = 3; float pwidth; motor.period_ms(30); motor.pulsewidth(pwidth); pc.printf("fast\n"); motor1 = 1; } else if(s=='5'){ pc.printf("stop\n"); motor1 = 3; } } int main() { pc.attach(drivecommand, Serial::RxIrq); pc.printf("HELLO WORLD\n"); while(1) { } }