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
main.cpp
- Committer:
- MatsumotoKouki
- Date:
- 2022-02-12
- Revision:
- 1:fd48964c294a
- Parent:
- 0:8cc9c11c6785
File content as of revision 1:fd48964c294a:
#include "mbed.h" #include "Serial.h" DigitalOut cam_sw1(D10); //カメラの電源スイッチに接続(Highで電源ON) DigitalOut cam_sw2(D9); //カメラの撮影スイッチ(FET)に接続(HighでD-S導通) DigitalOut IM_busy(PA_0); Serial device(PA_2,PA_3); Serial im920(PA_9,PA_10); Serial pc(USBTX, USBRX); DigitalOut led(LED1); char str[100]; int i=0; int k=0; char buf[100]; void cmd(){ while(1) { if(im920.readable()) { //IM920からのデータがある場合 char temp = im920.getc();//一文字読み込む pc.printf("%c",temp); if(temp != '\n') { //読み込み文字が改行で無い場合(順番では\r\n) str[i++] = temp; } else if(temp == '\n') { //読み込み文字が改行の場合 //printf("get Command\r\n"); }if(str[i-2]=='1'&&str[i-1]=='1'){ //スリープに入るor抜け出す際にはコマンド"11" //printf("get 11 !!\r\n"); cam_sw1 = 1; //カメラの電源スイッチON wait(3); cam_sw1 = 0; wait(10); //カメラの電源ON }else if(str[i-2]=='2'&&str[i-1]=='2'){ //撮影開始の際にはコマンド"22" cam_sw2 = 1; //撮影スイッチON(撮影開始指示) wait(0.2); //撮影開始 cam_sw2=0; printf("get 22\r\n"); }else if(str[i-2]=='3'&&str[i-1]=='3'){ //ス撮影終了の際にはコマンド"33" printf("get 33\r\n"); cam_sw2=1; //撮影スイッチON(撮影終了指示) wait(0.2); //撮影終了 cam_sw2=0; } /* im920.scanf("%s",buf); pc.printf("%s",buf); else if(str[i-1]=='A'||'a'||'B'||'b'||'C'||'c'){ device.putc(str[i-1]); }else{ im920.printf("command error"); printf("command error"); i=0; } */ } } } int main(){ //device.baud(9600); im920.baud(19200); pc.baud(38400); //device.attach(cmd,Serial::RxIrq); IM_busy=0; cmd(); }