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
Diff: main.cpp
- Revision:
- 26:c89f20803919
- Parent:
- 25:3a9580e58a5e
diff -r 3a9580e58a5e -r c89f20803919 main.cpp
--- a/main.cpp Sun Dec 15 03:12:13 2019 +0000
+++ b/main.cpp Sun Dec 15 04:32:30 2019 +0000
@@ -53,20 +53,20 @@
xbee.printf("timeout\n");
break;
}
- if(flight==1) {
+ else {if(flight==1) {
myled=1;
wait(10);
- printf("mada\r\n");
+
}
else{
if(flight==1) {
myled=1;
wait(10);
- xbee.printf("madamada\r\n");
+
}
else{
myled=0;
- xbee.printf("yattar\r\n");
+
wait(20);
FET=1;
wait(10);
@@ -74,11 +74,11 @@
wait(10);
xbee.printf("FET End!\r\n");
SW=0;
-
+ }
break;
}
}
- }
+ }
//以下GPS
@@ -89,7 +89,7 @@
int k = 0;
int j = 0;
- pc.printf("GPS Start\n");
+
xbee.printf("start\n");
time_gps.start();
while(a==0)
@@ -99,29 +99,29 @@
b=gps.longitude;
}
- pc.printf("%lf,%lf\n",a,b);/*着地地点の緯度と軽度を測る*/
- if(time_gps.read()>500){/*500経ったら次に進む*/
+
+ if(time_gps.read()>5){/*500経ったら次に進む*/
xbee.printf("timeout!!\n");/*xbeeで時間切れの場合はtimeoutと出力する*/
timeout_flag=1;
break;
}
}
- printf("moter on%lf",a);
+
left1 = 100; //左モーター100%
right1 = 100;//右モーター100%
wait(10);
- printf("moter off");
+
left1 = 0; //左モーター0%
right1 = 0;//右モーター0%
- printf("moter off");
+
wait(15);
while(!timeout_flag) {
- printf("GPS restart\n");
+ xbee.printf("GPS restart\n");
if(gps.getgps()){
- pc.printf("(%lf,%lf)\r\n",gps.latitude,gps.longitude);//緯度と経度を表示
+
j ++;
if(j<10){
}else{
@@ -131,7 +131,7 @@
lat2 = gps.latitude;
lon2 = gps.longitude;
- pc.printf("(%lf,%lf)\n\r",gps.latitude,gps.longitude);//動いた後の緯度と経度を表示
+
const double pi = 3.14159265359; // 円周率
double ra = a * pi / 180;
@@ -145,18 +145,17 @@
const double earth_radius = 6378140; // 地球赤道半径(m)
distance = earth_radius * rr; // 2点間の距離(m)
- printf("distance=%f\ne=%lf\nrr=%lf\n",distance,e,rr);
+
if (distance<5){
}else{
- pc.printf("(a =%lf,b =%lf)\n\r",a,b);
- pc.printf("(c =%lf,d =%lf)\n\r",gps.latitude,gps.longitude);//c,dを表示
- pc.printf("5m clear!");
+
xbee.printf("5m clear!");
+
break;
}
}
}else{
- printf("No data");
+
}
} //GPS End */
@@ -164,12 +163,12 @@
float th;
Timer tm;
for(i=0;i<3;i++){
- pc.printf("start\r\n");
+
left1 = 100; //左モーター100%
right1 = 100;//右モーター100%
- printf("Restart\r\n" );
+
wait(4);
left1=50;
@@ -179,7 +178,7 @@
right1=0;
wait(1);
- printf("停止\n\r");
+
Sb612switch=0; //焦電off
wait(1);
@@ -190,14 +189,14 @@
left1 = 0;
right1 = 0;
- printf("超音波on\r\n 焦電off\r\n" ) ;
+
hs.TrigerOut();
wait(1);
int distance;
distance = hs.GetDistance();
- printf("distance=%dmm\r\n",distance);//距離出力
+
if(distance<=2000){//超音波反応
Ultra=0;//超音波off
@@ -205,7 +204,7 @@
Sb612switch=1; //焦電on
wait(1);
- printf("焦電On!\r\n ");
+
bool detected=false;
th = thermo;
if(th==1 && !detected) {//焦電反応ありの場合
@@ -228,19 +227,19 @@
if (camera.isReady()) {
char filename[25];
snprintf(filename,25,"%s%03d%s","/local/pict",r,".jpg");
- printf("Picture: %s ", filename);
+
if (camera.takePicture(filename)) {
while (camera.isProcessing()) {
camera.processPicture();
- printf("take picture!");
+ xbee.printf("take a picture!");
- /*xbee.printf("xbee connected!!\r\n");
+
bs = new base64();
- bs->Encode(filename,"/local/data.txt");*/
+ bs->Encode(filename,"/local/data.txt");
- printf("time = %f\n", timer.read());
+
xbee.printf("xbee connected!!\r\n");
@@ -249,7 +248,7 @@
if((fp=fopen("/local/data.txt","r"))!=NULL){
- pc.printf("ok\r\n");
+
while((c=fgetc(fp))!=EOF){
xbee.printf("%c",c);
}
@@ -257,10 +256,10 @@
}
}
}else{
- printf("take picture failed\r\n");
+ ;
}
}else{
- printf("camera is not ready\r\n");
+ ;
}
while(1){