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.
Dependencies: ContinuousServo Tach mbed
stop.cpp@3:c1fe893d0353, 2018-04-26 (annotated)
- Committer:
- PlayaLarrea
- Date:
- Thu Apr 26 19:44:42 2018 +0000
- Revision:
- 3:c1fe893d0353
- Parent:
- 2:c97e01b25777
- Child:
- 4:7b311ca1ad32
14 gay shit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| PlayaLarrea | 0:4bc5c8484b75 | 1 | #include "mbed.h" |
| PlayaLarrea | 0:4bc5c8484b75 | 2 | #include "ContinuousServo.h" |
| PlayaLarrea | 0:4bc5c8484b75 | 3 | #include "Tach.h" |
| PlayaLarrea | 0:4bc5c8484b75 | 4 | |
| PlayaLarrea | 0:4bc5c8484b75 | 5 | ContinuousServo left(p23); |
| PlayaLarrea | 0:4bc5c8484b75 | 6 | ContinuousServo right(p26); |
| PlayaLarrea | 2:c97e01b25777 | 7 | AnalogIn sonar(p20); |
| PlayaLarrea | 2:c97e01b25777 | 8 | Ticker ultra; |
| PlayaLarrea | 3:c1fe893d0353 | 9 | Serial pc(USBTX,USBRX); |
| PlayaLarrea | 2:c97e01b25777 | 10 | |
| PlayaLarrea | 3:c1fe893d0353 | 11 | float wall; |
| PlayaLarrea | 3:c1fe893d0353 | 12 | float analog; |
| PlayaLarrea | 3:c1fe893d0353 | 13 | float range; |
| PlayaLarrea | 3:c1fe893d0353 | 14 | |
| PlayaLarrea | 0:4bc5c8484b75 | 15 | void update() { |
| PlayaLarrea | 3:c1fe893d0353 | 16 | wall = 102.04*sonar.read(); |
| PlayaLarrea | 3:c1fe893d0353 | 17 | pc.printf("%f\r\n", wall); |
| PlayaLarrea | 0:4bc5c8484b75 | 18 | } |
| PlayaLarrea | 0:4bc5c8484b75 | 19 | |
| PlayaLarrea | 0:4bc5c8484b75 | 20 | int main() { |
| PlayaLarrea | 2:c97e01b25777 | 21 | ultra.attach(&update, .25); |
| PlayaLarrea | 0:4bc5c8484b75 | 22 | |
| PlayaLarrea | 3:c1fe893d0353 | 23 | while(wall>12.0) { // main code for driving goes here |
| PlayaLarrea | 0:4bc5c8484b75 | 24 | left.speed(.5); |
| PlayaLarrea | 0:4bc5c8484b75 | 25 | right.speed(-.5); |
| PlayaLarrea | 0:4bc5c8484b75 | 26 | } |
| PlayaLarrea | 3:c1fe893d0353 | 27 | left.stop(); |
| PlayaLarrea | 3:c1fe893d0353 | 28 | right.stop(); |
| PlayaLarrea | 0:4bc5c8484b75 | 29 | } |