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.
direction.cpp@0:d8f0c4ba09cc, 2012-10-11 (annotated)
- Committer:
- lucoby
- Date:
- Thu Oct 11 18:54:32 2012 +0000
- Revision:
- 0:d8f0c4ba09cc
initial
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lucoby | 0:d8f0c4ba09cc | 1 | #include "mbed.h" |
| lucoby | 0:d8f0c4ba09cc | 2 | #include "direction.h" |
| lucoby | 0:d8f0c4ba09cc | 3 | |
| lucoby | 0:d8f0c4ba09cc | 4 | AnalogIn horz(p18); |
| lucoby | 0:d8f0c4ba09cc | 5 | AnalogIn vert(p19); |
| lucoby | 0:d8f0c4ba09cc | 6 | |
| lucoby | 0:d8f0c4ba09cc | 7 | SDirection getDirection(SDirection direction) { |
| lucoby | 0:d8f0c4ba09cc | 8 | float x = horz; |
| lucoby | 0:d8f0c4ba09cc | 9 | float y = vert; |
| lucoby | 0:d8f0c4ba09cc | 10 | if(vert > 0.75) { |
| lucoby | 0:d8f0c4ba09cc | 11 | direction = up; |
| lucoby | 0:d8f0c4ba09cc | 12 | } else if(vert < 0.25) { |
| lucoby | 0:d8f0c4ba09cc | 13 | direction = down; |
| lucoby | 0:d8f0c4ba09cc | 14 | } else if(horz > 0.75) { |
| lucoby | 0:d8f0c4ba09cc | 15 | direction = left; |
| lucoby | 0:d8f0c4ba09cc | 16 | } else if(horz < 0.25) { |
| lucoby | 0:d8f0c4ba09cc | 17 | direction = right; |
| lucoby | 0:d8f0c4ba09cc | 18 | } |
| lucoby | 0:d8f0c4ba09cc | 19 | return direction; |
| lucoby | 0:d8f0c4ba09cc | 20 | } |