cansat_B 2019 / Mbed 2 deprecated tougou-no3

Dependencies:   mbed

Committer:
seijakunouenimutou
Date:
Sun Nov 17 10:08:05 2019 +0000
Revision:
2:c799e2dde99f
Parent:
1:2611f01f2e9b
Child:
3:f70ecf1e21d5
CameraUS015sb612-3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KINU 0:f728b8e6bdf2 1 #include "mbed.h"
KINU 0:f728b8e6bdf2 2 #include "JPEGCamera.h"
KINU 0:f728b8e6bdf2 3 #include "us015.h"
KINU 0:f728b8e6bdf2 4 DigitalOut myled(LED1);
KINU 0:f728b8e6bdf2 5 US015 hs(p12,p11);
KINU 0:f728b8e6bdf2 6 DigitalOut thermo(p20);
KINU 0:f728b8e6bdf2 7 DigitalOut Ultra(p12);
KINU 0:f728b8e6bdf2 8 Serial pc(USBTX,USBRX); // tx, rx
KINU 0:f728b8e6bdf2 9 JPEGCamera camera(p9, p10); // TX, RX
KINU 0:f728b8e6bdf2 10 int main(){
seijakunouenimutou 2:c799e2dde99f 11 int i=1;
KINU 0:f728b8e6bdf2 12 float th;
KINU 0:f728b8e6bdf2 13 Timer tm;
seijakunouenimutou 2:c799e2dde99f 14 for(i=0;i<3;i++){
KINU 0:f728b8e6bdf2 15 pc.printf("start\r\n");
KINU 0:f728b8e6bdf2 16
KINU 0:f728b8e6bdf2 17 bool detected=false;
KINU 0:f728b8e6bdf2 18 thermo=0; //焦電off
KINU 0:f728b8e6bdf2 19 Ultra=1;//超音波on
seijakunouenimutou 2:c799e2dde99f 20 printf("超音波on 焦電off" ) ;
KINU 0:f728b8e6bdf2 21 while(1) {
KINU 0:f728b8e6bdf2 22 hs.TrigerOut();
KINU 0:f728b8e6bdf2 23 wait(1);
KINU 0:f728b8e6bdf2 24 int distance;
KINU 0:f728b8e6bdf2 25 distance = hs.GetDistance();
KINU 0:f728b8e6bdf2 26 printf("%d\r\n",distance);//距離出力
KINU 0:f728b8e6bdf2 27
KINU 0:f728b8e6bdf2 28 if(distance<2000){//超音波反応
KINU 0:f728b8e6bdf2 29 Ultra=0;//超音波off
KINU 0:f728b8e6bdf2 30 thermo=1;//焦電on
seijakunouenimutou 1:2611f01f2e9b 31 printf("音波off焦電on ");
KINU 0:f728b8e6bdf2 32 if(true)
KINU 0:f728b8e6bdf2 33 th = thermo;
KINU 0:f728b8e6bdf2 34 if(th=1 && !detected) {//焦電反応ありの場合
seijakunouenimutou 2:c799e2dde99f 35 i++;
KINU 0:f728b8e6bdf2 36 detected=true;
KINU 0:f728b8e6bdf2 37 pc.printf("human\r\n");
KINU 0:f728b8e6bdf2 38 tm.reset();
KINU 0:f728b8e6bdf2 39 tm.start();
KINU 0:f728b8e6bdf2 40
KINU 0:f728b8e6bdf2 41 LocalFileSystem local("local");
KINU 0:f728b8e6bdf2 42 Timer timer;
KINU 0:f728b8e6bdf2 43 timer.start();
KINU 0:f728b8e6bdf2 44 camera.setPictureSize(JPEGCamera::SIZE320x240);
KINU 0:f728b8e6bdf2 45
seijakunouenimutou 2:c799e2dde99f 46
KINU 0:f728b8e6bdf2 47 if (camera.isReady()) {
KINU 0:f728b8e6bdf2 48 char filename[32];
KINU 0:f728b8e6bdf2 49 sprintf(filename, "/local/pict%03d.jpg",i);
KINU 0:f728b8e6bdf2 50 printf("Picture: %s ", filename);
KINU 0:f728b8e6bdf2 51 if (camera.takePicture(filename)) {
KINU 0:f728b8e6bdf2 52 while (camera.isProcessing()) {
KINU 0:f728b8e6bdf2 53 camera.processPicture();
KINU 0:f728b8e6bdf2 54 printf("take pictuer!");
KINU 0:f728b8e6bdf2 55 }
KINU 0:f728b8e6bdf2 56 } else {
KINU 0:f728b8e6bdf2 57 printf("take picture failed\r\n");
KINU 0:f728b8e6bdf2 58 }
KINU 0:f728b8e6bdf2 59 } else {
KINU 0:f728b8e6bdf2 60 printf("camera is not ready\r\n");
KINU 0:f728b8e6bdf2 61 }
seijakunouenimutou 2:c799e2dde99f 62
KINU 0:f728b8e6bdf2 63 printf("time = %f\n", timer.read());
KINU 0:f728b8e6bdf2 64 }
KINU 0:f728b8e6bdf2 65
KINU 0:f728b8e6bdf2 66
KINU 0:f728b8e6bdf2 67
KINU 0:f728b8e6bdf2 68 }else{//焦電反応なしの場合
KINU 0:f728b8e6bdf2 69 detected=false;
KINU 0:f728b8e6bdf2 70 }
KINU 0:f728b8e6bdf2 71 }
KINU 0:f728b8e6bdf2 72
KINU 0:f728b8e6bdf2 73 }
seijakunouenimutou 2:c799e2dde99f 74 }
KINU 0:f728b8e6bdf2 75