Tests data at the analogue In. whilst the push button is being depressed (push button pulls input to ground when depressed). Writes this to a csv type file that can be opened in excel and graphed.
main.cpp@0:5bd82da0cad9, 2010-11-28 (annotated)
- Committer:
- WarwickRacing
- Date:
- Sun Nov 28 17:05:40 2010 +0000
- Revision:
- 0:5bd82da0cad9
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
WarwickRacing | 0:5bd82da0cad9 | 1 | #include "mbed.h" |
WarwickRacing | 0:5bd82da0cad9 | 2 | #include "DebouncedIn.h" |
WarwickRacing | 0:5bd82da0cad9 | 3 | |
WarwickRacing | 0:5bd82da0cad9 | 4 | LocalFileSystem local("local"); |
WarwickRacing | 0:5bd82da0cad9 | 5 | |
WarwickRacing | 0:5bd82da0cad9 | 6 | DebouncedIn ChangeUp(p15); //Debounced class creating digital input to invoke a gear change up |
WarwickRacing | 0:5bd82da0cad9 | 7 | AnalogIn Position(p20); //Analogue input to read current position of actuator from POT |
WarwickRacing | 0:5bd82da0cad9 | 8 | |
WarwickRacing | 0:5bd82da0cad9 | 9 | int i = 0; |
WarwickRacing | 0:5bd82da0cad9 | 10 | |
WarwickRacing | 0:5bd82da0cad9 | 11 | int main() { |
WarwickRacing | 0:5bd82da0cad9 | 12 | |
WarwickRacing | 0:5bd82da0cad9 | 13 | while(1) |
WarwickRacing | 0:5bd82da0cad9 | 14 | { |
WarwickRacing | 0:5bd82da0cad9 | 15 | FILE *Datalogging = fopen("/local/testAnalogue.csv", "w"); |
WarwickRacing | 0:5bd82da0cad9 | 16 | while(ChangeUp.falling()) |
WarwickRacing | 0:5bd82da0cad9 | 17 | { |
WarwickRacing | 0:5bd82da0cad9 | 18 | i++; |
WarwickRacing | 0:5bd82da0cad9 | 19 | fprintf(Datalogging, "%.3f,%.3f\n",Position.read(),i); |
WarwickRacing | 0:5bd82da0cad9 | 20 | } |
WarwickRacing | 0:5bd82da0cad9 | 21 | fclose(Datalogging); |
WarwickRacing | 0:5bd82da0cad9 | 22 | } |
WarwickRacing | 0:5bd82da0cad9 | 23 | } |