Created an example programme that uses the RenBuggy_Servo library. RenBuggy Figure Of Eight
Dependencies: RenBuggy_Timed
main.cpp@1:da2f06538364, 2014-05-08 (annotated)
- Committer:
- jf1452
- Date:
- Thu May 08 07:17:56 2014 +0000
- Revision:
- 1:da2f06538364
- Parent:
- 0:794a1188e0e3
RenBuggy Figure Of Eight
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Markatron | 0:794a1188e0e3 | 1 | /******************************************************************************* |
jf1452 | 1:da2f06538364 | 2 | * Used to drive RenBuggy with 2 wheels for a specified amount of time. * |
jf1452 | 1:da2f06538364 | 3 | * Copyright (c) 2014 Renishaw plc * |
jf1452 | 1:da2f06538364 | 4 | * * |
jf1452 | 1:da2f06538364 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy * |
jf1452 | 1:da2f06538364 | 6 | * of this software and associated documentation files (the "Software"), to deal* |
jf1452 | 1:da2f06538364 | 7 | * in the Software without restriction, including without limitation the rights * |
jf1452 | 1:da2f06538364 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * |
jf1452 | 1:da2f06538364 | 9 | * copies of the Software, and to permit persons to whom the Software is * |
jf1452 | 1:da2f06538364 | 10 | * furnished to do so, subject to the following conditions: * |
jf1452 | 1:da2f06538364 | 11 | * * |
jf1452 | 1:da2f06538364 | 12 | * The above copyright notice and this permission notice shall be included in * |
jf1452 | 1:da2f06538364 | 13 | * all copies or substantial portions of the Software. * |
jf1452 | 1:da2f06538364 | 14 | * * |
jf1452 | 1:da2f06538364 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * |
jf1452 | 1:da2f06538364 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * |
jf1452 | 1:da2f06538364 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * |
jf1452 | 1:da2f06538364 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * |
jf1452 | 1:da2f06538364 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,* |
jf1452 | 1:da2f06538364 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * |
jf1452 | 1:da2f06538364 | 21 | * THE SOFTWARE. * |
jf1452 | 1:da2f06538364 | 22 | * * |
jf1452 | 1:da2f06538364 | 23 | * RenBuggy_Timed_Program * |
jf1452 | 1:da2f06538364 | 24 | * * |
jf1452 | 1:da2f06538364 | 25 | * V1.0 8/5/2014 Jon Fuge * |
Markatron | 0:794a1188e0e3 | 26 | *******************************************************************************/ |
Markatron | 0:794a1188e0e3 | 27 | |
jf1452 | 1:da2f06538364 | 28 | // We are using the buggy with no wheel encoders so we need to use the timed |
jf1452 | 1:da2f06538364 | 29 | // library. |
Markatron | 0:794a1188e0e3 | 30 | #include "RenBuggyTimed.h" |
Markatron | 0:794a1188e0e3 | 31 | |
jf1452 | 1:da2f06538364 | 32 | RenBuggy myBuggy(p5, p6, p8, p7); // Configure control pins for the buggy |
jf1452 | 1:da2f06538364 | 33 | |
jf1452 | 1:da2f06538364 | 34 | // For this buggy, we only need to use the motor control pins p5 & p6. |
jf1452 | 1:da2f06538364 | 35 | // p5 controls the left motor |
jf1452 | 1:da2f06538364 | 36 | // p6 controls the right motor |
Markatron | 0:794a1188e0e3 | 37 | |
Markatron | 0:794a1188e0e3 | 38 | int main() { |
jf1452 | 1:da2f06538364 | 39 | int iCircleTime; |
jf1452 | 1:da2f06538364 | 40 | int iForwardTime; |
Markatron | 0:794a1188e0e3 | 41 | |
jf1452 | 1:da2f06538364 | 42 | iCircleTime = 22; // This is the time in seconds to do one full circle |
jf1452 | 1:da2f06538364 | 43 | iForwardTime = 1; // This is the time to move forwards |
jf1452 | 1:da2f06538364 | 44 | |
jf1452 | 1:da2f06538364 | 45 | myBuggy.stop(); |
jf1452 | 1:da2f06538364 | 46 | myBuggy.left(iCircleTime); |
jf1452 | 1:da2f06538364 | 47 | myBuggy.forward(iForwardTime); |
jf1452 | 1:da2f06538364 | 48 | myBuggy.right(iCircleTime); |
jf1452 | 1:da2f06538364 | 49 | myBuggy.forward(iForwardTime); |
jf1452 | 1:da2f06538364 | 50 | myBuggy.stop(); |
Markatron | 0:794a1188e0e3 | 51 | |
Markatron | 0:794a1188e0e3 | 52 | return 0; |
Markatron | 0:794a1188e0e3 | 53 | } |