|
求助大神,小弟卡在最后一步,如何在ssd 1306 OLED上实时显示脉搏传感器的数据(以波形图的方式,就像是电视里心率跳到的那样)
#include <Adafruit_SSD1306.h>
#include <U8g2_for_Adafruit_GFX.h>
#define width 128
#define height 64
Adafruit_SSD1306 display(/*MOSI*/ 11, /*CLK*/ 13, /*DC*/ 9, /*RESET*/ 8, /*CS*/ 10);
Adafruit_SSD1306 oled(128, 64,11,13,9,8,10);
U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx;
#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>
const int PulseWire = 0;
int Signal;
int Threshold = 550;
PulseSensorPlayground pulseSensor;
void setup() {
display.begin(SSD1306_SWITCHCAPVCC);
u8g2_for_adafruit_gfx.begin(display);
pulseSensor.analogInput(PulseWire);
pulseSensor.setThreshold(Threshold);
if (pulseSensor.begin()) {
u8g2_for_adafruit_gfx.println("We created a pulseSensor Object !");
}
void loop()
{ int myBPM = pulseSensor.getBeatsPerMinute();
int IBI=pulseSensor.getInterBeatIntervalMs();
display.clearDisplay();
u8g2_for_adafruit_gfx.setFont(u8g2_font_t0_11_tf);
u8g2_for_adafruit_gfx.setFontMode(1);
u8g2_for_adafruit_gfx.setFontDirection(0);
u8g2_for_adafruit_gfx.setForegroundColor(WHITE);
u8g2_for_adafruit_gfx.setCursor(0,10);
u8g2_for_adafruit_gfx.print("BPM");
u8g2_for_adafruit_gfx.setCursor(0,30);
u8g2_for_adafruit_gfx.println(myBPM);
u8g2_for_adafruit_gfx.setCursor(30,10);
u8g2_for_adafruit_gfx.println("IBI");
u8g2_for_adafruit_gfx.setCursor(30,30);
u8g2_for_adafruit_gfx.println(IBI);
Signal=analogRead(PulseWire) ;
u8g2_for_adafruit_gfx.setCursor(50,30);
u8g2_for_adafruit_gfx.println(Signal);
display.display();
delay(20);
}
|
|