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
Movement.cpp
- Committer:
- Mikebob
- Date:
- 2020-03-17
- Revision:
- 1:401bcbb58715
- Parent:
- 0:0285394cacfa
- Child:
- 2:878b6fd215d7
File content as of revision 1:401bcbb58715:
#include "mbed.h"
#include "motor.h"
#include "UltraSonic.h"
#include "clickers.h"
extern bool rStopped, fStopped;
extern Motor Wheel;
extern int HallState;
extern void dist();
extern Serial pc;
int i = 0;
void Direction (){
switch(HallState)
{
case 0:
if(fStopped == false){
dist();
if (i<1)
{
Wheel.Speed(1.0,1.0);//forward 100%
pc.printf("Do this once\n\r");
i++;
}
//FwdStop();
}
else if (fStopped == true)
HallState = 1;
break;
case 1:
if(fStopped == true && rStopped == false){
Wheel.Speed(-1.0,-1.0);//backward 100%
RevStop();
dist();
}
else if(fStopped == true && rStopped == true)
HallState = 2;
break;
case 2:
Wheel.Speed(1.0,-1.0);//Right 100%
wait_ms(500);
Wheel.Speed(1.0,1.0);//forward 100%
wait_ms(500);
Wheel.Speed(-1.0,1.0);//Left 100%
wait_ms(500);
Wheel.Stop();
HallState = 3;
break;
case 3:
{
}
}
}