Control a dual DC motor powered buggy using the BBC MicroBit
main.cpp@1:e2fc7f9cbdde, 2016-06-22 (annotated)
- Committer:
- elijah_ubit
- Date:
- Wed Jun 22 15:07:04 2016 +0000
- Revision:
- 1:e2fc7f9cbdde
- Parent:
- 0:370b7f440dcf
first
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elijah_ubit | 0:370b7f440dcf | 1 | /* |
elijah_ubit | 0:370b7f440dcf | 2 | MicroBitBuggy |
elijah_ubit | 0:370b7f440dcf | 3 | |
elijah_ubit | 0:370b7f440dcf | 4 | A program that uses the MicroBit to control the movement of a small buggy. |
elijah_ubit | 0:370b7f440dcf | 5 | |
elijah_ubit | 0:370b7f440dcf | 6 | Copyright (c) 2016 Elijah Orr |
elijah_ubit | 0:370b7f440dcf | 7 | |
elijah_ubit | 0:370b7f440dcf | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy |
elijah_ubit | 0:370b7f440dcf | 9 | of this software and associated documentation files (the "Software"), to deal |
elijah_ubit | 0:370b7f440dcf | 10 | in the Software without restriction, including without limitation the rights |
elijah_ubit | 0:370b7f440dcf | 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
elijah_ubit | 0:370b7f440dcf | 12 | copies of the Software, and to permit persons to whom the Software is |
elijah_ubit | 0:370b7f440dcf | 13 | furnished to do so, subject to the following conditions: |
elijah_ubit | 0:370b7f440dcf | 14 | |
elijah_ubit | 0:370b7f440dcf | 15 | The above copyright notice and this permission notice shall be included in |
elijah_ubit | 0:370b7f440dcf | 16 | all copies or substantial portions of the Software. |
elijah_ubit | 0:370b7f440dcf | 17 | |
elijah_ubit | 0:370b7f440dcf | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
elijah_ubit | 0:370b7f440dcf | 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
elijah_ubit | 0:370b7f440dcf | 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
elijah_ubit | 0:370b7f440dcf | 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
elijah_ubit | 0:370b7f440dcf | 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
elijah_ubit | 0:370b7f440dcf | 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
elijah_ubit | 0:370b7f440dcf | 24 | THE SOFTWARE. |
elijah_ubit | 0:370b7f440dcf | 25 | |
elijah_ubit | 0:370b7f440dcf | 26 | */ |
elijah_ubit | 0:370b7f440dcf | 27 | |
elijah_ubit | 0:370b7f440dcf | 28 | #include "MicroBit.h" |
elijah_ubit | 0:370b7f440dcf | 29 | #include "buggy_functions.h" //"buggy_functions.h" contains the functions that we will use to move the buggy |
elijah_ubit | 0:370b7f440dcf | 30 | |
elijah_ubit | 0:370b7f440dcf | 31 | /* The basic functions available are: |
elijah_ubit | 0:370b7f440dcf | 32 | * |
elijah_ubit | 0:370b7f440dcf | 33 | * forward(time); |
elijah_ubit | 0:370b7f440dcf | 34 | * left(time); |
elijah_ubit | 0:370b7f440dcf | 35 | * right(time); |
elijah_ubit | 0:370b7f440dcf | 36 | * hold(time); |
elijah_ubit | 0:370b7f440dcf | 37 | * |
elijah_ubit | 0:370b7f440dcf | 38 | * see buggy_functions.h for a full list. |
elijah_ubit | 0:370b7f440dcf | 39 | */ |
elijah_ubit | 0:370b7f440dcf | 40 | |
elijah_ubit | 0:370b7f440dcf | 41 | int main() //int main is run automatically. Place your program here |
elijah_ubit | 0:370b7f440dcf | 42 | { |
elijah_ubit | 0:370b7f440dcf | 43 | stop(); |
elijah_ubit | 1:e2fc7f9cbdde | 44 | while(1){ |
elijah_ubit | 1:e2fc7f9cbdde | 45 | forward(6); //move the buggy forward for 10 seconds |
elijah_ubit | 1:e2fc7f9cbdde | 46 | right(8); |
elijah_ubit | 1:e2fc7f9cbdde | 47 | forward(5); |
elijah_ubit | 1:e2fc7f9cbdde | 48 | left(2); |
elijah_ubit | 1:e2fc7f9cbdde | 49 | } |
elijah_ubit | 0:370b7f440dcf | 50 | } |