スポンサーリンク

心拍センサ SEN-11574

s_heart.png
  • 耳たぶや指先にセンサを付けて計測
    • 出力:アナログ電圧出力
    • 電源:3~5 V

Arduinoとの接続

  • 心拍センサとArduinoを以下のように接続する。
    Pin心拍センサ信号名Arduino備考
    1Vo(紫)任意のアナログ入力(A0~A5)
    2GND(黒)GND
    3Vcc(赤)5V

    pulse-setsuzoku.png

サンプルコード

  • 「ファイル」→「スケッチの例」→「06.Sensors」→「SEN-11574」
    /*
    ・sparkfunの心拍センサ SEN-11574 のサンプルプログラムです。
    ・2m秒ごとに心拍を測定し、シリアルモニタに出力します。
    ・マイコンボードに書き込み後、「ツール」→「シリアルモニタ」を起動してください。
    ・Arduinoとの接続
        1 Vo (紫) 任意のアナログ入力(A0~A5)
        2 GND(黒) GND
       3 Vcc(赤) 5V
    */
    
    int pulsePin = 0;                 // Pulse Sensor purple wire connected to analog pin 0
    
    // Volatile Variables, used in the interrupt service routine!
    volatile int BPM;                   // int that holds raw Analog in 0. updated every 2mS
    volatile int Signal;                // holds the incoming raw data
    volatile int IBI = 600;             // int that holds the time interval between beats! Must be seeded! 
    volatile boolean Pulse = false;     // "True" when User's live heartbeat is detected. "False" when not a "live beat". 
    volatile boolean QS = false;        // becomes true when Arduoino finds a beat.
    
    void setup(){
      Serial.begin(115200);             // we agree to talk fast!
      interruptSetup();                 // sets up to read Pulse Sensor signal every 2mS 
      // IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE, 
      // UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN
    //   analogReference(EXTERNAL);   
    }
    
    void loop(){
      sendDataToSerial('S', Signal);     // goes to sendDataToSerial function
      if (QS == true){     // A Heartbeat Was Found
                           // BPM and IBI have been Determined
                           // Quantified Self "QS" true when arduino finds a heartbeat
            sendDataToSerial('B',BPM);   // send heart rate with a 'B' prefix
            sendDataToSerial('Q',IBI);   // send time between beats with a 'Q' prefix
            QS = false;                      // reset the Quantified Self flag for next time    
      }
        
      delay(20);                             //  take a break
    }
    
    //  Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers. 
    void sendDataToSerial(char symbol, int data ){
        Serial.print(symbol);
        Serial.println(data);                
    }

実行例

pulse-sirial.png

参考資料


Total:10201 / Today:1 / Yesterday:0

スポンサーリンク


添付ファイル: filepulse-sirial.png 1246件 [詳細] files_heart.png 1142件 [詳細] filepulse-setsuzoku.png 1242件 [詳細]

トップ   差分 バックアップ リロード   一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2015-10-13 (火) 11:18:11