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.
Dependents: ROCO104_Buggy BuggyDesign
clickers.cpp@2:2571dd52276f, 2020-03-06 (annotated)
- Committer:
- jakesmart
- Date:
- Fri Mar 06 16:54:11 2020 +0000
- Revision:
- 2:2571dd52276f
- Parent:
- 1:d5b76569b45c
- Child:
- 3:91541ffdf9a5
Added stop boolean variable.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Mikebob | 0:cfb1fcccadd6 | 1 | #include "mbed.h" |
| Mikebob | 0:cfb1fcccadd6 | 2 | #include "motor.h" |
| Mikebob | 0:cfb1fcccadd6 | 3 | #include "clickers.h" |
| jakesmart | 2:2571dd52276f | 4 | #include "UltraSonic.h" |
| Mikebob | 0:cfb1fcccadd6 | 5 | |
| Mikebob | 0:cfb1fcccadd6 | 6 | extern DigitalIn microswitch1; //Instance of the DigitalIn class called 'microswitch1' |
| Mikebob | 0:cfb1fcccadd6 | 7 | extern DigitalIn microswitch2; //Instance of the DigitalIn class called 'microswitch2' |
| Mikebob | 0:cfb1fcccadd6 | 8 | extern Motor Wheel; |
| Mikebob | 1:d5b76569b45c | 9 | extern Serial pc; |
| Mikebob | 1:d5b76569b45c | 10 | extern int mm; |
| jakesmart | 2:2571dd52276f | 11 | extern void dist(); |
| jakesmart | 2:2571dd52276f | 12 | extern bool rStopped, fStopped; |
| jakesmart | 2:2571dd52276f | 13 | |
| Mikebob | 0:cfb1fcccadd6 | 14 | void RevStop() |
| Mikebob | 0:cfb1fcccadd6 | 15 | { |
| jakesmart | 2:2571dd52276f | 16 | while (microswitch1 == true) |
| Mikebob | 0:cfb1fcccadd6 | 17 | { |
| jakesmart | 2:2571dd52276f | 18 | microswitch1.read(); |
| Mikebob | 0:cfb1fcccadd6 | 19 | Wheel.Stop(); |
| jakesmart | 2:2571dd52276f | 20 | rStopped = true; |
| jakesmart | 2:2571dd52276f | 21 | } |
| jakesmart | 2:2571dd52276f | 22 | |
| jakesmart | 2:2571dd52276f | 23 | void FwdStop() |
| jakesmart | 2:2571dd52276f | 24 | { |
| jakesmart | 2:2571dd52276f | 25 | while (mm<= 500) |
| jakesmart | 2:2571dd52276f | 26 | { |
| jakesmart | 2:2571dd52276f | 27 | ultra_sonic_distance(); |
| jakesmart | 2:2571dd52276f | 28 | Wheel.Stop(); |
| jakesmart | 2:2571dd52276f | 29 | fStopped = true |
| jakesmart | 2:2571dd52276f | 30 | dist(); |
| Mikebob | 0:cfb1fcccadd6 | 31 | } |
| Mikebob | 0:cfb1fcccadd6 | 32 | } |