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

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?

UserRevisionLine numberNew 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.cpp *
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_C
Markatron 0:a413eedb9896 29 #define RENBUGGYTIMED_C
Markatron 0:a413eedb9896 30
Markatron 0:a413eedb9896 31 #include "RenBuggyTimed.h"
Markatron 0:a413eedb9896 32
Markatron 0:a413eedb9896 33 RenBuggy::RenBuggy(PinName leftMotor, PinName rightMotor,
Markatron 0:a413eedb9896 34 PinName leftBrake, PinName rightBrake) :
Markatron 0:a413eedb9896 35 m_motorL(leftMotor), m_motorR(rightMotor),
Markatron 0:a413eedb9896 36 m_brakeL(leftBrake), m_brakeR(rightBrake) {
Markatron 0:a413eedb9896 37
Markatron 0:a413eedb9896 38
Markatron 0:a413eedb9896 39 }
Markatron 0:a413eedb9896 40
Markatron 0:a413eedb9896 41 RenBuggy::~RenBuggy() {
Markatron 0:a413eedb9896 42 }
Markatron 0:a413eedb9896 43
Markatron 0:a413eedb9896 44 void RenBuggy::forward(float time) {
Markatron 0:a413eedb9896 45
Markatron 0:a413eedb9896 46 m_motorL = m_motorR = 1.0;
Markatron 0:a413eedb9896 47 wait(time);
Markatron 0:a413eedb9896 48 }
Markatron 0:a413eedb9896 49
Markatron 0:a413eedb9896 50 void RenBuggy::left(float time) {
Markatron 0:a413eedb9896 51
Markatron 0:a413eedb9896 52 m_motorL = 0.2;
Markatron 0:a413eedb9896 53 m_motorR = 1.0;
Markatron 0:a413eedb9896 54 wait(time);
Markatron 0:a413eedb9896 55 }
Markatron 0:a413eedb9896 56
Markatron 0:a413eedb9896 57 void RenBuggy::right(float time) {
Markatron 0:a413eedb9896 58
Markatron 0:a413eedb9896 59 m_motorL = 1.0;
Markatron 0:a413eedb9896 60 m_motorR = 0.2;
Markatron 0:a413eedb9896 61 wait(time);
Markatron 0:a413eedb9896 62 }
Markatron 0:a413eedb9896 63
Markatron 0:a413eedb9896 64 void RenBuggy::stop() {
Markatron 0:a413eedb9896 65
Markatron 0:a413eedb9896 66 m_motorL = m_motorR = 0;
Markatron 0:a413eedb9896 67 m_brakeL = m_brakeR = 1.0;
Markatron 0:a413eedb9896 68 }
Markatron 0:a413eedb9896 69
Markatron 0:a413eedb9896 70 #endif // RENBUGGYTIMED_C