Bluetooth program for the Seeed bot
Dependencies: BluetoothSerial SeeedShieldBot mbed
Fork of Seeed_BlueBot_demo by
Diff: main.cpp
- Revision:
- 5:de5b38436960
- Parent:
- 4:5dd60bfc3cdd
- Child:
- 6:a15e7918258f
--- a/main.cpp Fri Oct 24 08:27:19 2014 +0000 +++ b/main.cpp Thu May 21 08:49:34 2015 +0000 @@ -8,9 +8,17 @@ BluetoothSerial bluetooth(D1, D0); // TX, RX +#ifdef TARGET_NUCLEO_L053R8 +#define PWM1 D6 // Connect D6 and D8 +#define PWM2 D12 +#else // NUCLEO_F072RB +#define PWM1 D8 +#define PWM2 D12 +#endif + SeeedStudioShieldBot bot( - D8, D9, D11, // Right motor pins (PwmOut, DigitalOut, DigitalOut) -> Motor 1 - D12, D10, D13, // Left motor pins (PwmOut, DigitalOut, DigitalOut) -> Motor 2 + PWM1, D9, D11, // Right motor pins (PwmOut, DigitalOut, DigitalOut) -> Motor 1 + PWM2, D10, D13, // Left motor pins (PwmOut, DigitalOut, DigitalOut) -> Motor 2 A0, A1, A2, A3, A4 // Sensors pins (all DigitalIn) ); @@ -20,7 +28,7 @@ // Enable it for debugging on hyperterminal #define DEBUG 0 #if DEBUG == 1 -Serial pc(PC_10, PC_11); +Serial pc(PC_10, PC_11); // Connect PC10 and CN3-RX #define PC_DEBUG(args...) pc.printf(args) #else #define PC_DEBUG(args...) @@ -58,16 +66,22 @@ case '4': // Right bot.right(speed); break; - case '5': // Turn left + case '5': // Turn left forward bot.turn_right(speed); break; - case '6': // Turn right + case '6': // Turn right forward bot.turn_left(speed); break; - case '7': // Slow - speed = 0.4; + case '7': // Turn left backward + bot.turn_right(-speed); break; - case '8': // Fast + case '8': // Turn right backward + bot.turn_left(-speed); + break; + case '9': // Slow + speed = 0.5; + break; + case 'A': // Fast speed = 1.0; break; default: // Stop @@ -90,7 +104,7 @@ PC_DEBUG("done\n"); PC_DEBUG(">>> Bluetooth in slave mode..."); - bluetooth.slave("btslave8seeed"); // default PIN code: 0000 + bluetooth.slave("bt_seeed_1"); // default PIN code: 0000 PC_DEBUG("done\n"); wait(2);