諒太 宮澤
/
motor_test
単輪試験機用モータドライバテスト
Diff: main.cpp
- Revision:
- 0:f577792e4c6c
diff -r 000000000000 -r f577792e4c6c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 12 07:48:50 2016 +0000 @@ -0,0 +1,56 @@ +//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) { + + } +} \ No newline at end of file