Script voor aansturen motoren
Dependencies: Encoder HIDScope MODSERIAL mbed-dsp mbed
Diff: main.cpp
- Revision:
- 4:db3dad7e53e3
- Parent:
- 3:dcc4cebba0d7
- Child:
- 5:e4b9cc904928
--- a/main.cpp Wed Oct 22 13:04:35 2014 +0000 +++ b/main.cpp Wed Oct 22 13:23:30 2014 +0000 @@ -14,7 +14,7 @@ #define M2_DIR PTA4 //groen Serial pc(USBTX, USBRX); -DigitalOut led1(LED_RED); +DigitalOut led1(LED_RED); void clamp(float * in, float min, float max); @@ -48,13 +48,23 @@ pwm_motor2.period_us(75); DigitalOut motordir2(M1_DIR); //PTA4, groen - + char c ='0'; while(1) { - - pwm_motor1.write(1); - wait(3); - pwm_motor1.write(0); - wait(3); + pwm_motor1.write(1); + motordir1.write(1); + do { + + if(pc.readable()) { + c = pc.getc(); + } + } + while((c !='1')); + { + c = '0'; + pwm_motor1.write(0.5); + motordir1.write(0); + wait(3); + } } }