Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:ae5d19a716e1, 2014-03-05 (annotated)
- Committer:
- Nishii
- Date:
- Wed Mar 05 05:17:45 2014 +0000
- Revision:
- 0:ae5d19a716e1
for Robot Grand Prix
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Nishii | 0:ae5d19a716e1 | 1 | /* main.cpp */ |
| Nishii | 0:ae5d19a716e1 | 2 | |
| Nishii | 0:ae5d19a716e1 | 3 | /** |
| Nishii | 0:ae5d19a716e1 | 4 | * Includes |
| Nishii | 0:ae5d19a716e1 | 5 | */ |
| Nishii | 0:ae5d19a716e1 | 6 | #include "mbed.h" |
| Nishii | 0:ae5d19a716e1 | 7 | #include "QEI.h" |
| Nishii | 0:ae5d19a716e1 | 8 | #include "global.h" |
| Nishii | 0:ae5d19a716e1 | 9 | |
| Nishii | 0:ae5d19a716e1 | 10 | /** |
| Nishii | 0:ae5d19a716e1 | 11 | * main |
| Nishii | 0:ae5d19a716e1 | 12 | */ |
| Nishii | 0:ae5d19a716e1 | 13 | int main() { |
| Nishii | 0:ae5d19a716e1 | 14 | |
| Nishii | 0:ae5d19a716e1 | 15 | char c; |
| Nishii | 0:ae5d19a716e1 | 16 | |
| Nishii | 0:ae5d19a716e1 | 17 | //default value |
| Nishii | 0:ae5d19a716e1 | 18 | mortar_A.period_us(50); |
| Nishii | 0:ae5d19a716e1 | 19 | mortar_A = STOP; |
| Nishii | 0:ae5d19a716e1 | 20 | mortar_U = STOP; |
| Nishii | 0:ae5d19a716e1 | 21 | mortar_M = STOP; |
| Nishii | 0:ae5d19a716e1 | 22 | mortar_S = STOP; |
| Nishii | 0:ae5d19a716e1 | 23 | UFO = CLOSE; |
| Nishii | 0:ae5d19a716e1 | 24 | RISE1 = RISE2 = RISE3 = DOWN; |
| Nishii | 0:ae5d19a716e1 | 25 | MS_A.mode(PullUp); |
| Nishii | 0:ae5d19a716e1 | 26 | MS_U.mode(PullUp); |
| Nishii | 0:ae5d19a716e1 | 27 | MS_M.mode(PullUp); |
| Nishii | 0:ae5d19a716e1 | 28 | MS_S.mode(PullUp); |
| Nishii | 0:ae5d19a716e1 | 29 | |
| Nishii | 0:ae5d19a716e1 | 30 | pc.putc('I'); //Initialize PC program |
| Nishii | 0:ae5d19a716e1 | 31 | wait(0.5); |
| Nishii | 0:ae5d19a716e1 | 32 | |
| Nishii | 0:ae5d19a716e1 | 33 | AUTO(); |
| Nishii | 0:ae5d19a716e1 | 34 | |
| Nishii | 0:ae5d19a716e1 | 35 | pc.printf( "\r\n" ); |
| Nishii | 0:ae5d19a716e1 | 36 | wait(0.2); |
| Nishii | 0:ae5d19a716e1 | 37 | while(1) { |
| Nishii | 0:ae5d19a716e1 | 38 | c = pc.getc(); |
| Nishii | 0:ae5d19a716e1 | 39 | switch(c) { |
| Nishii | 0:ae5d19a716e1 | 40 | case 'A': |
| Nishii | 0:ae5d19a716e1 | 41 | AUTO(); |
| Nishii | 0:ae5d19a716e1 | 42 | break; |
| Nishii | 0:ae5d19a716e1 | 43 | case 'M': |
| Nishii | 0:ae5d19a716e1 | 44 | MANUAL(); |
| Nishii | 0:ae5d19a716e1 | 45 | break; |
| Nishii | 0:ae5d19a716e1 | 46 | case 'S': |
| Nishii | 0:ae5d19a716e1 | 47 | SEMIAUTO(); |
| Nishii | 0:ae5d19a716e1 | 48 | break; |
| Nishii | 0:ae5d19a716e1 | 49 | } |
| Nishii | 0:ae5d19a716e1 | 50 | pc.printf( "\r\n" ); |
| Nishii | 0:ae5d19a716e1 | 51 | wait(0.2); |
| Nishii | 0:ae5d19a716e1 | 52 | } |
| Nishii | 0:ae5d19a716e1 | 53 | } |