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: mbed URF MD_MDDS30_oit_ ros_lib_melodic
URF_check.txt
- Committer:
- akihiron
- Date:
- 2022-05-03
- Revision:
- 0:450a7208c682
File content as of revision 0:450a7208c682:
#include "mbed.h"
#include "URF.h"
Serial pc(USBTX, USBRX, 115200);
URF usdRight(D6);
URF usdLeft(D8);
Ticker update;
DigitalOut led(LED1);
DigitalOut led2(PC_4);
DigitalIn btn(USER_BUTTON);
void inter(void)
{
usdRight.send();
usdLeft.send();
}
void URF(int dataRight, int dataLeft){
if(dataRight>100 && dataRight<=230){
pc.printf("right slow\n");
//Yonrin(-0.3f, 0);
if(dataLeft>100 && dataLeft<=230){
pc.printf("left slow\n");
//Yonrin(0.3f, 0);
}
else if(dataLeft<=100){
pc.printf("left stop\n");
//Yonrin(0);
}
}
else if(dataRight<=100){
pc.printf("right stop\n");
//Yonrin(0);
if(dataLeft>100 && dataLeft<=230){
pc.printf("left slow\n");
//Yonrin(0.3f, 0);
}
else if(dataLeft<=100){
pc.printf("left stop\n");
//Yonrin(0);
}
}
else if(dataLeft>100 && dataLeft<=230){
pc.printf("left slow\n");
//Yonrin(0.3f, 0);
if(dataRight>100 && dataRight<=230){
pc.printf("right slow\n");
//Yonrin(-0.3f, 0);
}
else if(dataRight<=100){
pc.printf("right stop\n");
//Yonrin(0);
}
}
else if(dataLeft<=100){
pc.printf("left stop\n");
//Yonrin(0);
if(dataRight>100 && dataRight<=230){
pc.printf("right slow\n");
//Yonrin(-0.3f, 0);
}
else if(dataRight<=100){
pc.printf("right stop\n");
//Yonrin(0);
}
}
}
int main(){
pc.printf("check1\n");
update.attach(&inter, 0.06);
while(1){
int dataRight = usdRight.read(mm);
int dataLeft = usdLeft.read(mm);
//pc.printf("right: %d, left: %d\n", dataRight, dataLeft);
if(dataRight<=230 || dataLeft<=230){
URF(dataRight,dataLeft);
}
}
}