Nucleo board with Seeed bot and bluetooth shields demo.
Dependencies: BluetoothSerial SeeedShieldBot mbed
This code shows a simple application composed of a Nucleo board, a Seeed Bot and Seeed Bluetooth shieds:
- http://mbed.org/components/Seeed-Studio-Shield-Robot
- http://mbed.org/components/Seeed-Bluetooth-Shield
This picture shows how the three boards are stacked together:
You will need also to use an application on your phone to send Bluetooth commands and to be able to control the Bot shield. We have used the Bluetooth spp tools pro Android application.
Look at this video to have more details about this demo:
Revision 5:de5b38436960, committed 2015-05-21
- Comitter:
- bcostm
- Date:
- Thu May 21 08:49:34 2015 +0000
- Parent:
- 4:5dd60bfc3cdd
- Commit message:
- - Show how to use another Nucleo board (L053R8 for example)
; - Add commands
Changed in this revision
--- 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);
--- a/mbed-src.lib Fri Oct 24 08:27:19 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-src/#1b8acea4af63
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 21 08:49:34 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/dbbf35b96557 \ No newline at end of file