![](/media/cache/group/Renishaw_CMYK_logo_black_strap.jpg.50x50_q85.jpg)
Library for use with the RenBuggy with 2 wheels that travels for an amount of time specified by the user.
Dependencies: mbed
Dependents: RenBuggy_Timed_Programme RenBuggy_Figure_Of_Eight
RenBuggyTimed.h@0:a413eedb9896, 2014-03-31 (annotated)
- Committer:
- Markatron
- Date:
- Mon Mar 31 10:18:38 2014 +0000
- Revision:
- 0:a413eedb9896
Created a library for use with the RenBuggy with 2 wheels that travels for an amount of time specified by the user.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Markatron | 0:a413eedb9896 | 1 | /******************************************************************************* |
Markatron | 0:a413eedb9896 | 2 | * Used to drive RenBuggy with 2 wheels for a specified amount of time. * |
Markatron | 0:a413eedb9896 | 3 | * Copyright (c) 2014 Mark Jones * |
Markatron | 0:a413eedb9896 | 4 | * * |
Markatron | 0:a413eedb9896 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy * |
Markatron | 0:a413eedb9896 | 6 | * of this software and associated documentation files (the "Software"), to deal* |
Markatron | 0:a413eedb9896 | 7 | * in the Software without restriction, including without limitation the rights * |
Markatron | 0:a413eedb9896 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * |
Markatron | 0:a413eedb9896 | 9 | * copies of the Software, and to permit persons to whom the Software is * |
Markatron | 0:a413eedb9896 | 10 | * furnished to do so, subject to the following conditions: * |
Markatron | 0:a413eedb9896 | 11 | * * |
Markatron | 0:a413eedb9896 | 12 | * The above copyright notice and this permission notice shall be included in * |
Markatron | 0:a413eedb9896 | 13 | * all copies or substantial portions of the Software. * |
Markatron | 0:a413eedb9896 | 14 | * * |
Markatron | 0:a413eedb9896 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * |
Markatron | 0:a413eedb9896 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * |
Markatron | 0:a413eedb9896 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * |
Markatron | 0:a413eedb9896 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * |
Markatron | 0:a413eedb9896 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,* |
Markatron | 0:a413eedb9896 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * |
Markatron | 0:a413eedb9896 | 21 | * THE SOFTWARE. * |
Markatron | 0:a413eedb9896 | 22 | * * |
Markatron | 0:a413eedb9896 | 23 | * RenBuggyTimed.h * |
Markatron | 0:a413eedb9896 | 24 | * * |
Markatron | 0:a413eedb9896 | 25 | * V1.0 31/03/2014 Mark Jones * |
Markatron | 0:a413eedb9896 | 26 | *******************************************************************************/ |
Markatron | 0:a413eedb9896 | 27 | |
Markatron | 0:a413eedb9896 | 28 | #ifndef RENBUGGYTIMED_H |
Markatron | 0:a413eedb9896 | 29 | #define RENBUGGYTIMED_H |
Markatron | 0:a413eedb9896 | 30 | |
Markatron | 0:a413eedb9896 | 31 | #include "mbed.h" |
Markatron | 0:a413eedb9896 | 32 | |
Markatron | 0:a413eedb9896 | 33 | /** |
Markatron | 0:a413eedb9896 | 34 | * RenBuggyTimed example: |
Markatron | 0:a413eedb9896 | 35 | * @code |
Markatron | 0:a413eedb9896 | 36 | |
Markatron | 0:a413eedb9896 | 37 | #include "RenBuggyTimed.h" |
Markatron | 0:a413eedb9896 | 38 | |
Markatron | 0:a413eedb9896 | 39 | RenBuggy myBuggy(p5, p6, p8, p7); |
Markatron | 0:a413eedb9896 | 40 | |
Markatron | 0:a413eedb9896 | 41 | int main() { |
Markatron | 0:a413eedb9896 | 42 | |
Markatron | 0:a413eedb9896 | 43 | myBuggy.forward(4); |
Markatron | 0:a413eedb9896 | 44 | myBuggy.left(3); |
Markatron | 0:a413eedb9896 | 45 | myBuggy.forward(4); |
Markatron | 0:a413eedb9896 | 46 | myBuggy.right(3); |
Markatron | 0:a413eedb9896 | 47 | |
Markatron | 0:a413eedb9896 | 48 | return 0; |
Markatron | 0:a413eedb9896 | 49 | } |
Markatron | 0:a413eedb9896 | 50 | @endcode |
Markatron | 0:a413eedb9896 | 51 | */ |
Markatron | 0:a413eedb9896 | 52 | |
Markatron | 0:a413eedb9896 | 53 | /** |
Markatron | 0:a413eedb9896 | 54 | * The class used to control a timed version |
Markatron | 0:a413eedb9896 | 55 | * of the RenBuggy with 2 wheels. |
Markatron | 0:a413eedb9896 | 56 | */ |
Markatron | 0:a413eedb9896 | 57 | class RenBuggy { |
Markatron | 0:a413eedb9896 | 58 | |
Markatron | 0:a413eedb9896 | 59 | private: |
Markatron | 0:a413eedb9896 | 60 | PwmOut m_motorL; |
Markatron | 0:a413eedb9896 | 61 | PwmOut m_motorR; |
Markatron | 0:a413eedb9896 | 62 | |
Markatron | 0:a413eedb9896 | 63 | DigitalOut m_brakeL; |
Markatron | 0:a413eedb9896 | 64 | DigitalOut m_brakeR; |
Markatron | 0:a413eedb9896 | 65 | |
Markatron | 0:a413eedb9896 | 66 | public: |
Markatron | 0:a413eedb9896 | 67 | /** |
Markatron | 0:a413eedb9896 | 68 | * Constructs the class with the pins for the pwm outputs |
Markatron | 0:a413eedb9896 | 69 | * and the digital outputs, to move and stop. |
Markatron | 0:a413eedb9896 | 70 | */ |
Markatron | 0:a413eedb9896 | 71 | RenBuggy(PinName leftMotor, PinName rightMotor, |
Markatron | 0:a413eedb9896 | 72 | PinName leftBrake, PinName rightBrake); |
Markatron | 0:a413eedb9896 | 73 | /** |
Markatron | 0:a413eedb9896 | 74 | * Deconstructs the buggy. |
Markatron | 0:a413eedb9896 | 75 | */ |
Markatron | 0:a413eedb9896 | 76 | ~RenBuggy(); |
Markatron | 0:a413eedb9896 | 77 | |
Markatron | 0:a413eedb9896 | 78 | /** |
Markatron | 0:a413eedb9896 | 79 | * Moves the buggy forward for a specified amount of time. |
Markatron | 0:a413eedb9896 | 80 | */ |
Markatron | 0:a413eedb9896 | 81 | void forward(float time); |
Markatron | 0:a413eedb9896 | 82 | |
Markatron | 0:a413eedb9896 | 83 | /** |
Markatron | 0:a413eedb9896 | 84 | * Turns the buggy forward and left for a specified amount of time. |
Markatron | 0:a413eedb9896 | 85 | */ |
Markatron | 0:a413eedb9896 | 86 | void left(float time); |
Markatron | 0:a413eedb9896 | 87 | |
Markatron | 0:a413eedb9896 | 88 | /** |
Markatron | 0:a413eedb9896 | 89 | * Turns the buggy forward and right for a specified amount of time. |
Markatron | 0:a413eedb9896 | 90 | */ |
Markatron | 0:a413eedb9896 | 91 | void right(float time); |
Markatron | 0:a413eedb9896 | 92 | |
Markatron | 0:a413eedb9896 | 93 | /** |
Markatron | 0:a413eedb9896 | 94 | * Applies the brakes. |
Markatron | 0:a413eedb9896 | 95 | */ |
Markatron | 0:a413eedb9896 | 96 | void stop(); |
Markatron | 0:a413eedb9896 | 97 | |
Markatron | 0:a413eedb9896 | 98 | }; |
Markatron | 0:a413eedb9896 | 99 | |
Markatron | 0:a413eedb9896 | 100 | #endif // RENBUGGYTIMED_H |