Example program for the SeeedStudio Bot Shield, based on DigitalOut, PWM and AnalogIn pins.

Dependencies:   SeeedShieldBot mbed

Committer:
screamer
Date:
Thu Jul 31 14:48:28 2014 +0000
Revision:
1:d3c3ab54ee08
Parent:
0:330533a0be99
Child:
2:67a73907e626
Changed the Right motor pin; Changed the bot library name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:330533a0be99 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
screamer 0:330533a0be99 2 *
screamer 0:330533a0be99 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
screamer 0:330533a0be99 4 * and associated documentation files (the "Software"), to deal in the Software without
screamer 0:330533a0be99 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
screamer 0:330533a0be99 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
screamer 0:330533a0be99 7 * Software is furnished to do so, subject to the following conditions:
screamer 0:330533a0be99 8 *
screamer 0:330533a0be99 9 * The above copyright notice and this permission notice shall be included in all copies or
screamer 0:330533a0be99 10 * substantial portions of the Software.
screamer 0:330533a0be99 11 *
screamer 0:330533a0be99 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
screamer 0:330533a0be99 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
screamer 0:330533a0be99 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
screamer 0:330533a0be99 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
screamer 0:330533a0be99 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
screamer 0:330533a0be99 17 */
screamer 0:330533a0be99 18
screamer 0:330533a0be99 19 #include "mbed.h"
screamer 0:330533a0be99 20 #include "SeeedStudioShieldBot.h"
screamer 0:330533a0be99 21
screamer 0:330533a0be99 22 SeeedStudioShieldBot bot(
screamer 0:330533a0be99 23 D5, D6, D7, // Left motor pins
screamer 1:d3c3ab54ee08 24 D8, D9, D10, // Right motor pins
screamer 0:330533a0be99 25 A0, A1, A2, A3, D4 // Sensors pins
screamer 0:330533a0be99 26 );
screamer 0:330533a0be99 27 float speed = 0;
screamer 0:330533a0be99 28
screamer 0:330533a0be99 29 int main() {
screamer 0:330533a0be99 30 bot.enable_right_motor();
screamer 0:330533a0be99 31 bot.enable_left_motor();
screamer 0:330533a0be99 32
screamer 0:330533a0be99 33 while(1) {
screamer 0:330533a0be99 34 bot.stopAll();
screamer 0:330533a0be99 35 wait(1);
screamer 0:330533a0be99 36
screamer 0:330533a0be99 37 speed = 0;
screamer 0:330533a0be99 38 while (speed < 1) {
screamer 0:330533a0be99 39 speed += 0.1;
screamer 0:330533a0be99 40 bot.forward(speed);
screamer 0:330533a0be99 41 wait(1);
screamer 0:330533a0be99 42 };
screamer 0:330533a0be99 43 bot.stopAll();
screamer 0:330533a0be99 44 wait(1);
screamer 0:330533a0be99 45
screamer 0:330533a0be99 46 bot.turn_left(speed);
screamer 0:330533a0be99 47 wait(1);
screamer 0:330533a0be99 48 bot.right(speed);
screamer 0:330533a0be99 49 wait(1);
screamer 0:330533a0be99 50 bot.stopAll();
screamer 0:330533a0be99 51 wait(1);
screamer 0:330533a0be99 52
screamer 0:330533a0be99 53 bot.turn_right(speed);
screamer 0:330533a0be99 54 wait(1);
screamer 0:330533a0be99 55 bot.left(speed);
screamer 0:330533a0be99 56 wait(1);
screamer 0:330533a0be99 57 bot.stopAll();
screamer 0:330533a0be99 58 wait(1);
screamer 0:330533a0be99 59 }
screamer 0:330533a0be99 60 }