Arduinoでセンサ-とカメラを活用するには

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
takero-
記事: 9
登録日時: 8年前

Arduinoでセンサ-とカメラを活用するには

#1

投稿記事 by takero- » 8年前

[1] 質問文
 [1.1] 自分が今行いたい事は何か:
私の果樹園には色々な鳥獣が出て悪さをします。これを監視するセンサーカメラを作りたいと思っています。
Arduinoというものができて初心者向けだと聞き、次のスケッチというものを作りました。

 [1.2] どのように取り組んだか(プログラムコードがある場合記載)

コード:

// カメラと接続するピン
#define REL_HALF 12 // 半押し状態
#define RELEASE 11  // レリーズ

//センサーに接続するピン
#define SENCER 2

//インターバル60秒
#define INTERVAL_TIME (6000)

unsigned long half_time;

volatile boolean shoot = false;

void setup() 
{
   // ポート初期化
  pinMode(REL_HALF, OUTPUT);
  pinMode(RELEASE, OUTPUT);
  pinMode(SENCER, INPUT);

  digitalWrite(REL_HALF, LOW);
  digitalWrite(RELEASE, LOW);
  startSensing();


// 最初の半押しまでの時間を設定  
  half_time = millis() + INTERVAL_TIME;
}


  void loop() {
    unsigned long diff = half_time - millis();

    if (diff > 0) {
      delay(200);
    }
    else {
      digitalWrite(REL_HALF, HIGH);
      delay(200);
 // スイッチオフ
      digitalWrite(REL_HALF, LOW);
    
 // 次の半押し時間を設定
  half_time = millis() + INTERVAL_TIME;
    }
 
  
    if (shoot) { // センサが検知したときに1回だけ実行
      shoot = false;

      delay(200);
      digitalWrite(RELEASE, LOW); // シャッター閉
      delay(200);
      digitalWrite(REL_HALF, LOW);
    }
  }

  // センサ(フォトインタラプタ)の監視をはじめる
  void startSensing () {
    attachInterrupt(0, detected, RISING);
  }

  // 割り込み処理ルーチン
  void detected() {
    detachInterrupt(0);     // 割り込み無効化
    shoot = true;
  }
 [1.3] どのようなエラーやトラブルで困っているか(エラーメッセージが解る場合は記載)
検証時に
// 次の半押し時間を設定
half_time = millis() + INTERVAL_TIME;
}
というところでエラ-が出てしまいます。

Arduino:1.6.11 (Windows 7), ボード:"Arduino Nano, ATmega328"

C:\Program Files\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\Arduino\hardware -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files\Arduino\libraries -libraries C:\Users\nakamura\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files\Arduino\hardware\tools\avr -verbose C:\Users\nakamura\Documents\Arduino\libraries\eosDshoot2\eosDshoot2.ino
C:\Program Files\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files\Arduino\hardware -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files\Arduino\libraries -libraries C:\Users\nakamura\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files\Arduino\hardware\tools\avr -verbose C:\Users\nakamura\Documents\Arduino\libraries\eosDshoot2\eosDshoot2.ino
Using board 'nano' from platform in folder: C:\Program Files\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp\sketch\eosDshoot2.ino.cpp" -o "nul"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp\sketch\eosDshoot2.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp\sketch\eosDshoot2.ino.cpp" -o "C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files\Arduino\tools-builder\ctags\5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
スケッチをコンパイルしています...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp\sketch\eosDshoot2.ino.cpp" -o "C:\Users\nakamura\AppData\Local\Temp\builda4039b66fe2e02ddb15fc2b40541dc71.tmp\sketch\eosDshoot2.ino.cpp.o"
eosDshoot2:30: error: stray '\357' in program

half_time = millis() + INTERVAL_TIME;

^

eosDshoot2:30: error: stray '\274' in program

eosDshoot2:30: error: stray '\210' in program

eosDshoot2:30: error: stray '\357' in program

eosDshoot2:30: error: stray '\274' in program

eosDshoot2:30: error: stray '\211' in program

eosDshoot2:47: error: stray '\357' in program

half_time = millis() + INTERVAL_TIME;

^

eosDshoot2:47: error: stray '\274' in program

eosDshoot2:47: error: stray '\210' in program

eosDshoot2:47: error: stray '\357' in program

eosDshoot2:47: error: stray '\274' in program

eosDshoot2:47: error: stray '\211' in program

exit status 1
stray '\357' in program

 [1.4] 今何がわからないのか、知りたいのか
このエラーの意味するところを知りたいです。そして回避するには何をすればいいか知りたいです。

[2] 環境  
 [2.1] OS : Windows, Linux等々
Windows7

 [2.2] コンパイラ名 : VC++ 2008EE, Borand C++, gcc等々
Arduinoでいいのでしょうか?

[3] その他
 ・どの程度C言語を理解しているか
勉強初めて約3ヶ月です。
 ・ライブラリを使っている場合は何を使っているか
使っていないと思われます。

以上、初心者の質問でお恥ずかしいですがよろしくお願いします。
最後に編集したユーザー takero- on 2016年10月08日(土) 21:53 [ 編集 3 回目 ]

アバター
みけCAT
記事: 6734
登録日時: 14年前
住所: 千葉県
連絡を取る:

Re: Arduinoでセンサ-とカメラを活用するには

#2

投稿記事 by みけCAT » 8年前

ソースコードを提示する際は、BBCodeを有効にした(無効にしない)状態でBBCodeのcodeタグで囲んでいただけると、見やすくてありがたいです。
takero- さんが書きました:このエラーの意味するところを知りたいです。
不正な文字があります。
takero- さんが書きました:そして回避するには何をすればいいか知りたいです。
コメントや文字列以外の全角文字など、不正な文字を消せばいいでしょう。
必要に応じてバイナリエディタなどで不正な文字を探すのも有効かもしれません。
オフトピック
まずエラーメッセージでググってみましたか?
[search=google]error: stray '\357' in program[/search]
複雑な問題?マシンの性能を上げてOpenMPで殴ればいい!(死亡フラグ)

takero-
記事: 9
登録日時: 8年前

Re: Arduinoでセンサ-とカメラを活用するには

#3

投稿記事 by takero- » 8年前

みけCATさん、ご指導ありがとうございました。

全て、半角で打ち直しました。
すると、'startSensing' was not declared in this scope というエラーに変わりました。

これをググッたら、どこかで宣言していないからというような記載を見つけました。
void setup のなかで書くだけではいけないのでしょうか?

takero-
記事: 9
登録日時: 8年前

Re: Arduinoでセンサ-とカメラを活用するには

#4

投稿記事 by takero- » 8年前

setup や loop と同じように setup のなかに書くのをやめたところ、
コンパイルが完了しましたとのことでした。

あす、回路と組み合わせて試運転したいと思います。
お騒がせしました、ありがとうございました。

takero-
記事: 9
登録日時: 8年前

Re: Arduinoでセンサ-とカメラを活用するには

#5

投稿記事 by takero- » 8年前

今朝、回路と組み合わせましたが、
作動できませんでした。

まず、60秒間隔で半押しができませんでした。

次に、センサー感知で全押しもできませんでした。

1からやり直したいと思います。

閉鎖

“C言語何でも質問掲示板” へ戻る