A program that allows control of the RenBuggy by altering the relative speeds of the wheels.
main.cpp@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 | *RenBuggyTimed * |
RenBuggy | 0:9870f526ddd1 | 3 | *Author: Elijah Orr * |
RenBuggy | 0:9870f526ddd1 | 4 | * * |
RenBuggy | 0:9870f526ddd1 | 5 | *This program demonstates use of a library of functions * |
RenBuggy | 0:9870f526ddd1 | 6 | *(TimedMovement) to control the movement of the RenBuggy.* |
RenBuggy | 0:9870f526ddd1 | 7 | * * |
RenBuggy | 0:9870f526ddd1 | 8 | *********************************************************/ |
RenBuggy | 0:9870f526ddd1 | 9 | |
RenBuggy | 0:9870f526ddd1 | 10 | /* mbed.h is a library made by mbed.org that contains |
RenBuggy | 0:9870f526ddd1 | 11 | classes/functions designed to make programming mbed |
RenBuggy | 0:9870f526ddd1 | 12 | microcontrollers easier */ |
RenBuggy | 0:9870f526ddd1 | 13 | #include "mbed.h" |
RenBuggy | 0:9870f526ddd1 | 14 | /* #include tells the compiler to include TimedMovement.h |
RenBuggy | 0:9870f526ddd1 | 15 | and TimedMovement.cpp in the program */ |
RenBuggy | 0:9870f526ddd1 | 16 | #include "TimedMovement.h" |
RenBuggy | 0:9870f526ddd1 | 17 | |
RenBuggy | 0:9870f526ddd1 | 18 | /* the main function is where a program will begin to execute. */ |
RenBuggy | 0:9870f526ddd1 | 19 | |
RenBuggy | 0:9870f526ddd1 | 20 | /**************************************************************** |
RenBuggy | 0:9870f526ddd1 | 21 | * Function: main() * |
RenBuggy | 0:9870f526ddd1 | 22 | * * |
RenBuggy | 0:9870f526ddd1 | 23 | * Controls the movement of the RenBuggy by varying the speed * |
RenBuggy | 0:9870f526ddd1 | 24 | * of each motor * |
RenBuggy | 0:9870f526ddd1 | 25 | * * |
RenBuggy | 0:9870f526ddd1 | 26 | * Inputs: none * |
RenBuggy | 0:9870f526ddd1 | 27 | * * |
RenBuggy | 0:9870f526ddd1 | 28 | * Returns: none * |
RenBuggy | 0:9870f526ddd1 | 29 | ****************************************************************/ |
RenBuggy | 0:9870f526ddd1 | 30 | int main() |
RenBuggy | 0:9870f526ddd1 | 31 | { |
RenBuggy | 0:9870f526ddd1 | 32 | /* here we can call the functions defined in TimedMovement.h |
RenBuggy | 0:9870f526ddd1 | 33 | and TimedMovement.cpp, and specify the length of time we want |
RenBuggy | 0:9870f526ddd1 | 34 | them to run for by passing a variable which represents a |
RenBuggy | 0:9870f526ddd1 | 35 | length of time in seconds */ |
RenBuggy | 0:9870f526ddd1 | 36 | forward(5); |
RenBuggy | 0:9870f526ddd1 | 37 | left(2); |
RenBuggy | 0:9870f526ddd1 | 38 | forward(5); |
RenBuggy | 0:9870f526ddd1 | 39 | stop(); |
RenBuggy | 0:9870f526ddd1 | 40 | } |