![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
MD
Diff: main.cpp
- Revision:
- 1:770e1fc380ff
- Parent:
- 0:41f2e835aa5d
- Child:
- 2:f2b42e387d08
--- a/main.cpp Sun Sep 11 04:32:13 2016 +0000 +++ b/main.cpp Mon Sep 26 10:25:54 2016 +0000 @@ -20,17 +20,31 @@ NVIC_SetPriority(I2C_IRQn, 10); i2cslave i2c(dp5, dp27, Registar); /*change address every micon***********/ - i2c.address(MD1_addr); + i2c.address(MD6_addr); /**************************************/ i2c.frequency(1000000); Ticker tic; tic.attach(check, 0.1); + char prev_motor1_state = 0; + char prev_motor2_state = 0; while(1) { pwm1 = (float)(Registar[motor1_pwm]) / 255; pwm2 = (float)(Registar[motor2_pwm]) / 255; + if(Registar[motor1_state] != prev_motor1_state) + { + motor1 = 0; + wait_ms(5); + } + if(Registar[motor2_state] != prev_motor2_state) + { + motor2 = 0; + wait_ms(1); + } motor1 = Registar[motor1_state]; motor2 = Registar[motor2_state]; + prev_motor1_state = Registar[motor1_state]; + prev_motor2_state = Registar[motor2_state]; wait_ms(40); } }