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
- Committer:
- Mikebob
- Date:
- 2020-03-17
- Revision:
- 3:91541ffdf9a5
- Parent:
- 2:2571dd52276f
- Child:
- 4:595e353826e5
File content as of revision 3:91541ffdf9a5:
#include "mbed.h"
#include "motor.h"
#include "clickers.h"
#include "UltraSonic.h"
extern DigitalIn microswitch1; //Instance of the DigitalIn class called 'microswitch1'
extern DigitalIn microswitch2; //Instance of the DigitalIn class called 'microswitch2'
extern Motor Wheel;
extern Serial pc;
extern int mm;
extern void dist();
extern bool rStopped, fStopped;
int countDis = 0;
void RevStop()
{
if (microswitch1 == true)
{
microswitch1.read();
Wheel.Stop();
rStopped = true;
dist();
}
}
void FwdStop()
{
dist();
if (mm<= 500)
{
countDis++;
dist();
}
else if (mm<= 500 && countDis > 20)
{
Wheel.Stop();
fStopped = true;
dist();
}
else
{
countDis = 0;
fStopped = false;
dist();
}
}