A program that allows control of the RenBuggy by altering the relative speeds of the wheels.
TimedMovement.h@0:9870f526ddd1, 2016-03-11 (annotated)
- Committer:
- RenBuggy
- Date:
- Fri Mar 11 10:36:38 2016 +0000
- Revision:
- 0:9870f526ddd1
- Child:
- 1:dd956fbd7e95
version 1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RenBuggy | 0:9870f526ddd1 | 1 | /********************************************************* |
RenBuggy | 0:9870f526ddd1 | 2 | *TimedMovement.h * |
RenBuggy | 0:9870f526ddd1 | 3 | *Author: Elijah Orr * |
RenBuggy | 0:9870f526ddd1 | 4 | * * |
RenBuggy | 0:9870f526ddd1 | 5 | *A library of functions that can be used to control the * |
RenBuggy | 0:9870f526ddd1 | 6 | *RenBuggy. * |
RenBuggy | 0:9870f526ddd1 | 7 | *********************************************************/ |
RenBuggy | 0:9870f526ddd1 | 8 | |
RenBuggy | 0:9870f526ddd1 | 9 | /* include guards are used to prevent problems caused by |
RenBuggy | 0:9870f526ddd1 | 10 | multiple definitions */ |
RenBuggy | 0:9870f526ddd1 | 11 | #ifndef TIMEDMOVEMENT_H |
RenBuggy | 0:9870f526ddd1 | 12 | #define TIMEDMOVEMENT_H |
RenBuggy | 0:9870f526ddd1 | 13 | |
RenBuggy | 0:9870f526ddd1 | 14 | /* mbed.h must be included in this file also */ |
RenBuggy | 0:9870f526ddd1 | 15 | #include "mbed.h" |
RenBuggy | 0:9870f526ddd1 | 16 | |
RenBuggy | 0:9870f526ddd1 | 17 | /* #define LeftMotorPin p5 tells the preprocessor to replace |
RenBuggy | 0:9870f526ddd1 | 18 | any mention of LeftMotorPin with p5. This is used to select |
RenBuggy | 0:9870f526ddd1 | 19 | which pins to use to control the motors. Here pins 5 and 6 |
RenBuggy | 0:9870f526ddd1 | 20 | are used. */ |
RenBuggy | 0:9870f526ddd1 | 21 | #define LeftMotorPin p5 |
RenBuggy | 0:9870f526ddd1 | 22 | #define RightMotorPin p6 |
RenBuggy | 0:9870f526ddd1 | 23 | |
RenBuggy | 0:9870f526ddd1 | 24 | /* these are function prototypes that declare all the functions |
RenBuggy | 0:9870f526ddd1 | 25 | in the library. extern tells the compiler that the functions |
RenBuggy | 0:9870f526ddd1 | 26 | may be called in other files, such as main.cpp. void specifies |
RenBuggy | 0:9870f526ddd1 | 27 | that the function will not return a value, i.e. the program will |
RenBuggy | 0:9870f526ddd1 | 28 | execute the function and then move on the the next line of code. |
RenBuggy | 0:9870f526ddd1 | 29 | forward is the name of the function and float specifies that |
RenBuggy | 0:9870f526ddd1 | 30 | the function expects to be passed a variable of the format float. */ |
RenBuggy | 0:9870f526ddd1 | 31 | extern void forward(float); |
RenBuggy | 0:9870f526ddd1 | 32 | extern void left(float); |
RenBuggy | 0:9870f526ddd1 | 33 | extern void right(float); |
RenBuggy | 0:9870f526ddd1 | 34 | /* stop() is slightly different in that it doesn't expect to be passed |
RenBuggy | 0:9870f526ddd1 | 35 | any variables, so the parentheses can be left empty. Passing a variable |
RenBuggy | 0:9870f526ddd1 | 36 | to this function would cause an error */ |
RenBuggy | 0:9870f526ddd1 | 37 | extern void stop(); |
RenBuggy | 0:9870f526ddd1 | 38 | |
RenBuggy | 0:9870f526ddd1 | 39 | #endif // TIMEDMOVEMENT_H |