A program that allows control of the RenBuggy by altering the relative speeds of the wheels.
TimedMovement.h@5:9b6abababfd9, 2016-04-05 (annotated)
- Committer:
- RenBuggy
- Date:
- Tue Apr 05 06:55:15 2016 +0000
- Revision:
- 5:9b6abababfd9
- Parent:
- 4:68be3709e37a
- Child:
- 6:ce9b3fbdd856
v1.0
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 | 3:c12fbf373785 | 17 | /* #define LeftMotorPin PWM2 tells the preprocessor to replace |
RenBuggy | 3:c12fbf373785 | 18 | any mention of LeftMotorPin with PWM2. This is used to select |
RenBuggy | 5:9b6abababfd9 | 19 | which pins to use to control the motors. Here pins DIP10 and DIP25 |
RenBuggy | 5:9b6abababfd9 | 20 | are used, which correspond to PWM2 (P1_26) and PWM3 (P1_24). */ |
RenBuggy | 3:c12fbf373785 | 21 | #define LeftMotorPin PWM2 |
RenBuggy | 3:c12fbf373785 | 22 | #define RightMotorPin PWM3 |
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 | 4:68be3709e37a | 37 | void stop(); |
RenBuggy | 0:9870f526ddd1 | 38 | |
RenBuggy | 0:9870f526ddd1 | 39 | #endif // TIMEDMOVEMENT_H |