Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_RCBController2 by
Diff: main.cpp
- Revision:
- 7:6115339996eb
- Parent:
- 6:1b978b32118c
- Child:
- 9:ed80cfb10df8
--- a/main.cpp Thu Sep 11 14:02:31 2014 +0000 +++ b/main.cpp Tue Sep 16 13:09:22 2014 +0000 @@ -47,27 +47,26 @@ // pin asign DigitalOut tb6612_ain1(P0_28); DigitalOut tb6612_ain2(P0_29); -//PwmOut tb6612_pwma(P0_30); -//PwmOut servo_pwm (P0_12); -PwmOut servo_pwm (P0_30); +PwmOut tb6612_pwma(P0_30); +PwmOut servo_pwm (P0_12); // DC motor driver (TB6612) void motor (float speed) { if (speed > 0) { // CW - //tb6612_pwma = speed; + tb6612_pwma = speed; tb6612_ain1 = 1; tb6612_ain2 = 0; } else if (speed < 0) { // CCW - //tb6612_pwma = - speed; + tb6612_pwma = - speed; tb6612_ain1 = 0; tb6612_ain2 = 1; } else { // stop - //tb6612_pwma = 1; + tb6612_pwma = 1; tb6612_ain1 = 0; tb6612_ain2 = 0; // // break @@ -113,11 +112,9 @@ #endif float m = (float)stickData.value.fb / 128.0; motor(m); - float s = 0.5 + (float)stickData.value.lr /256.0; - if(s<0) s=0; - //servo(s); + float s = (float)stickData.value.lr / 128.0; + servo(s); } - } // Program entry point @@ -145,10 +142,10 @@ (const uint8_t *)UUID_BLUEPROPO, sizeof(UUID_BLUEPROPO)); ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */ ble.startAdvertising(); - ///ble.addService(serviceBluePropo); + ble.addService(serviceBluePropo); // main loop (wait for BLE event) while (true) { - //ble.waitForEvent(); + ble.waitForEvent(); } }