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.
Diff: main.cpp
- Revision:
- 8:c9a5ef6f003f
- Parent:
- 7:df29c4de6522
--- a/main.cpp Sun Dec 19 18:48:16 2021 +0000
+++ b/main.cpp Sun Dec 19 20:44:45 2021 +0000
@@ -30,6 +30,7 @@
double Time = 0;
#define Standby_Time 10
Serial pc(USBTX, USBRX);
+Serial LED(PB_6,PB_7);
char Serialdata;
BusOut myled(LED1, LED2, LED3, LED4);
@@ -96,6 +97,7 @@
//Serial
pc.attach(SerialRX);
//pc.baud(115200);
+ LED.baud(9600);
//CAN
canPort.frequency(1000000); //Bit Rate:1MHz
@@ -216,6 +218,7 @@
state_1 = 11;
}else{
set_MODE_T();
+ LED.printf("wait\n\r");
}
}else if(state_1 == 1){//前進→壁検出フェーズ
if(dist1 < WALL && dist1 >= 25){
@@ -225,6 +228,7 @@
set_DEC(ACC_C);//減速度設定
set_MODE_V();//速度制御モード送信
vel_forward(rpm);//前進速度指令
+ LED.printf("up\n\r");
}
}else if(state_1 == 2){//前進からの帰還フェーズ
if(ActPos > -3000){
@@ -234,6 +238,7 @@
//break;
}else{
vel_backward(rpm);
+ LED.printf("down\n\r");
}
}else if(state_1 == 11){//右進→壁検出フェーズ
if(dist3 < WALL && dist3 >= 25){
@@ -243,6 +248,7 @@
set_DEC(ACC_C);//減速度設定
set_MODE_V();//速度制御モード送信
vel_right(rpm);//前進速度指令
+ LED.printf("right\n\r");
}
}else if(state_1 == 12){//右進からの帰還フェーズ
if(ActPos < 3000){
@@ -252,6 +258,7 @@
//break;
}else{
vel_left(rpm);
+ LED.printf("left\n\r");
}
}
}