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@4:595e353826e5, 2020-03-17 (annotated)
- Committer:
- Mikebob
- Date:
- Tue Mar 17 15:22:38 2020 +0000
- Revision:
- 4:595e353826e5
- Parent:
- 3:91541ffdf9a5
- Child:
- 5:e32cc4bf5aac
Final;
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 | 4:595e353826e5 | 6 | //These externs allow variables and functiones to be used that in another folder/library |
| Mikebob | 0:cfb1fcccadd6 | 7 | extern DigitalIn microswitch1; //Instance of the DigitalIn class called 'microswitch1' |
| Mikebob | 0:cfb1fcccadd6 | 8 | extern DigitalIn microswitch2; //Instance of the DigitalIn class called 'microswitch2' |
| Mikebob | 0:cfb1fcccadd6 | 9 | extern Motor Wheel; |
| Mikebob | 1:d5b76569b45c | 10 | extern Serial pc; |
| Mikebob | 1:d5b76569b45c | 11 | extern int mm; |
| jakesmart | 2:2571dd52276f | 12 | extern void dist(); |
| jakesmart | 2:2571dd52276f | 13 | extern bool rStopped, fStopped; |
| Mikebob | 4:595e353826e5 | 14 | |
| Mikebob | 4:595e353826e5 | 15 | void RevStop()//This function will stop the buggy and change the bool to true to say the buggy has been stopped from going backwards |
| Mikebob | 0:cfb1fcccadd6 | 16 | { |
| Mikebob | 3:91541ffdf9a5 | 17 | if (microswitch1 == true) |
| Mikebob | 0:cfb1fcccadd6 | 18 | { |
| Mikebob | 4:595e353826e5 | 19 | microswitch1.read();//Read the state of the microswitch |
| Mikebob | 4:595e353826e5 | 20 | Wheel.Stop();//Stop wheels |
| Mikebob | 4:595e353826e5 | 21 | rStopped = true;//Change bool state to true |
| Mikebob | 4:595e353826e5 | 22 | dist();//Check distance |
| jakesmart | 2:2571dd52276f | 23 | } |
| Mikebob | 3:91541ffdf9a5 | 24 | } |
| Mikebob | 4:595e353826e5 | 25 | void FwdStop()//This function will stop the buggy and change the bool to true to say the buggy has been stopped from going forwards |
| jakesmart | 2:2571dd52276f | 26 | { |
| Mikebob | 4:595e353826e5 | 27 | if (mm<= 500)//Do the following if the buggy is less than 500mm to the edge of the arena |
| Mikebob | 3:91541ffdf9a5 | 28 | { |
| Mikebob | 4:595e353826e5 | 29 | Wheel.Stop();//Stop wheels |
| Mikebob | 4:595e353826e5 | 30 | fStopped = true;//Change bool state to true |
| Mikebob | 4:595e353826e5 | 31 | dist();//Check distance |
| Mikebob | 3:91541ffdf9a5 | 32 | } |
| Mikebob | 3:91541ffdf9a5 | 33 | else |
| Mikebob | 3:91541ffdf9a5 | 34 | { |
| Mikebob | 4:595e353826e5 | 35 | |
| Mikebob | 4:595e353826e5 | 36 | fStopped = false; //Keep bool state false |
| Mikebob | 4:595e353826e5 | 37 | dist();//Check distance |
| Mikebob | 0:cfb1fcccadd6 | 38 | } |
| Mikebob | 0:cfb1fcccadd6 | 39 | } |