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:
- 16:429f6ad98e90
- Parent:
- 15:1deffcfa5b1a
- Child:
- 17:2e0a775081ce
--- a/main.cpp Sat Dec 14 13:27:51 2019 +0000
+++ b/main.cpp Sat Dec 14 15:16:36 2019 +0000
@@ -198,105 +198,106 @@
Sb612switch=1; //焦電on
wait(1);
- printf("焦電On!\r\n ");
-
- bool detected=false;
- th = thermo;
-
- if(th==1 && !detected) {//焦電反応ありの場合
- i++;
- detected=true;
- pc.printf("human\r\n");
- tm.reset();
- tm.start();
-
- LocalFileSystem local("local");
- Timer timer;
- timer.start();
- camera.setPictureSize(JPEGCamera::SIZE320x240);
+ printf("焦電On!\r\n ");
+ bool detected=false;
+ th = thermo;
+ if(th==1 && !detected) {//焦電反応ありの場合
+ i++;
+ detected=true;
+ pc.printf("human\r\n");
+ tm.reset();
+ tm.start();
+
+ LocalFileSystem local("local");
+ Timer timer;
+ timer.start();
+ camera.setPictureSize(JPEGCamera::SIZE320x240);
- FILE *fp;
- base64 *bs;
- int c;
+ FILE *fp;
+ base64 *bs;
+ int c;
- for (int r = 0; r < 1; r++) {
- 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 pictuer!");
-
- xbee.printf("xbee connected!!\r\n");
-
- bs = new base64();
- bs->Encode(filename,"/local/data.txt");
+ for (int r = 0; r < 1; r++) {
+ if (camera.isReady()) {
+ char filename[32];
+ sprintf(filename, "/local/pict%03d.jpg",r);
+ printf("Picture: %s ", filename);
+ if (camera.takePicture(filename)) {
+ while (camera.isProcessing()) {
+ camera.processPicture();
+ printf("take pictuer!");
+ }
+ }else{
+ printf("take picture failed\r\n");
+ }
+ }else{
+ printf("camera is not ready\r\n");
+ }
- printf("time = %f\n", timer.read());
-
+ printf("time = %f\n", timer.read());
+
+
- if((fp=fopen("/local/d.txt","r"))!=NULL){
+ xbee.printf("xbee connected!\r\n");
+ bs = new base64();
+ bs->Encode("/local/pict000.jpg","/local/data000.txt");
+
+ if((fp=fopen("/local/data000.txt","r"))!=NULL)
+ {
pc.printf("ok\r\n");
while((c=fgetc(fp))!=EOF){
- xbee.printf("%c",c);
+ xbee.printf("%c",c);
}
fclose(fp);
- }
+ }
}
- }else{
- printf("take picture failed\r\n");
- }
- }else{
- printf("camera is not ready\r\n");
- }
- while(1){
+ while(1){
- int received_data = xbee.getc();
+ int received_data = xbee.getc();
- if (received_data == 82 || received_data == 114){ //Rまたはr
-
- xbee.printf("_________________________________________________________________________________________________________________________________\r\n");
- if((fp=fopen("/local/d.txt","r"))!=NULL) {
- while ((c=fgetc(fp))!=EOF){
-
- xbee.printf("%c",c); //再送
- }
- fclose(fp);
- }
- }else{
- break;
- }
- }
+ if (received_data == 82 || received_data == 114){ //Rまたはr
+ xbee.printf("_________________________________________________________________________________________________________________________________\r\n");
+ if((fp=fopen("/local/data000.txt","r"))!=NULL)
+ {
+ while ((c=fgetc(fp))!=EOF){
+ xbee.printf("%c",c); //再送
+ }
+ fclose(fp);
+ }
+ }
+ else{
+ break;
+ }
+ }
- Sb612switch=0; //焦電off
- wait(1);
- }
- }else{//焦電反応なしの場合
- printf("not found!\r\n");
- Sb612switch=0;
- wait(1);
- Ultra=0;
- wait(1);
- detected=false;
- printf("後退\r\n");
- left1 = -100; //左モーター-50%
- right1 = -100;//右モーター-50%
- wait(2.0);
- left1=-50;
- right1=-50;
- wait(1);
- left1=0;
- right1=0;
- wait(1);
+ Sb612switch=0; //焦電off
+ wait(1);
+ }else{//焦電反応なしの場合
+ printf("not found!\r\n");
+
- printf("右折\n\r");
- left1 = 60; //左モーター100%
- right1 = 100;//右モーター100%
- wait(2.0);
- }
+ Sb612switch=0;
+ wait(1);
+ Ultra=0;
+ wait(1);
+ detected=false;
+ printf("後退\r\n");
+ left1 = -100; //左モーター-50%
+ right1 = -100;//右モーター-50%
+ wait(2.0);
+ left1=-50;
+ right1=-50;
+ wait(1);
+ left1=0;
+ right1=0;
+ wait(1);
+
+ printf("右折\n\r");
+
+ left1 = 60; //左モーター100%
+ right1 = 100;//右モーター100%
+ wait(2.0);
+ }
}else{//超音波distance>2000
printf("safety zone\r\n");
Ultra=0;