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:
- 0:f728b8e6bdf2
- Child:
- 1:2611f01f2e9b
diff -r 000000000000 -r f728b8e6bdf2 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Nov 15 14:02:01 2019 +0000 @@ -0,0 +1,71 @@ +#include "mbed.h" +#include "JPEGCamera.h" +#include "us015.h" +DigitalOut myled(LED1); +US015 hs(p12,p11); +DigitalOut thermo(p20); +DigitalOut Ultra(p12); +Serial pc(USBTX,USBRX); // tx, rx +JPEGCamera camera(p9, p10); // TX, RX +int main(){ + float th; + Timer tm; + pc.printf("start\r\n"); + + bool detected=false; + thermo=0; //焦電off + Ultra=1;//超音波on + + while(1) { + hs.TrigerOut(); + wait(1); + int distance; + distance = hs.GetDistance(); + printf("%d\r\n",distance);//距離出力 + + if(distance<2000){//超音波反応 + Ultra=0;//超音波off + thermo=1;//焦電on + if(true) + th = thermo; + if(th=1 && !detected) {//焦電反応ありの場合 + detected=true; + pc.printf("human\r\n"); + tm.reset(); + tm.start(); + + LocalFileSystem local("local"); + Timer timer; + timer.start(); + camera.setPictureSize(JPEGCamera::SIZE320x240); + + for (int i = 0; i < 1; i++) { + if (camera.isReady()) { + char filename[32]; + sprintf(filename, "/local/pict%03d.jpg",i); + 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()); + } + + + + }else{//焦電反応なしの場合 + detected=false; + } +} + + } + + \ No newline at end of file