1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉

標題: 脈搏傳感器 [打印本頁]

作者: ttt123321    時間: 2018-10-9 09:46
標題: 脈搏傳感器
對于下面這個程序我還有點不明覺厲 希望大佬能解釋一下
#include <Adafruit_SSD1306.h>

#define OLED_Address 0x3C
Adafruit_SSD1306 oled(1);

int x=0;
int lastx=0;
int lasty=0;
int LastTime=0;
bool BPMTiming=false;
bool BeatComplete=false;
int BPM=0;

#define UpperThreshold 550
#define LowerThreshold 500

void setup() {
  oled.begin(SSD1306_SWITCHCAPVCC, OLED_Address);
  oled.clearDisplay();
  oled.setTextSize(2);
}


void loop()
{
  if(x>127)  
  {
    oled.clearDisplay();
    x=0;
    lastx=x;
  }

  int value=analogRead(0);
  oled.setTextColor(WHITE);
  int y=20-(value/45);
  oled.writeLine(lastx,lasty,x,y,WHITE);
  lasty=y;
  lastx=x;
  // calc bpm

  if(value>UpperThreshold)
  {
    if(BeatComplete)
    {
      BPM=millis()-LastTime;
      BPM=int(60/(float(BPM)/1000));
      BPMTiming=false;
      BeatComplete=false;
    }
    if(BPMTiming==false)
    {
      LastTime=millis();
      BPMTiming=true;
    }
  }
  if((value<LowerThreshold)&(BPMTiming))
    BeatComplete=true;
    // display bpm
  oled.writeFillRect(0,19,128,20,BLACK);
  oled.setCursor(0,19);
  oled.print(BPM);
  oled.print(" BPM");
  oled.display();
  x++;
}







歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1