BASIC4MCU | 질문게시판 | 아두이노 블루투스 전송
페이지 정보
작성자 으아아악 작성일2019-05-27 02:33 조회9,509회 댓글2건본문
#define PROCESSING_VISUALIZER 1
#define SERIAL_PLOTTER 2
#include <SoftwareSerial.h>
// Variables
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.
SoftwareSerial BTSerial(2, 3);
// SET THE SERIAL OUTPUT TYPE TO YOUR NEEDS
// PROCESSING_VISUALIZER works with Pulse Sensor Processing Visualizer
// https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer
// SERIAL_PLOTTER outputs sensor data for viewing with the Arduino Serial Plotter
// run the Serial Plotter at 115200 baud: Tools/Serial Plotter or Command+L
static int outputType = SERIAL_PLOTTER;
void setup(){
BTSerial.begin(9600);
Serial.begin(9600); // 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);
}
// Where the Magic Happens
void loop(){
serialOutput() ;
BTSerial.print(BPM );
delay(1000);
if (QS == true){ // A Heartbeat Was Found
// BPM and IBI have been Determined
// Quantified Self "QS" true when arduino finds a heartbeat
// Set 'fadeRate' Variable to 255 to fade LED with pulse
serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.
QS = false; // reset the Quantified Self flag for next time
}
}
위처럼 심박 측정 코드를 작성하고 앱인벤터로 앱을 만들어 실행시켜 보았는데 측정된 심박수가 일정하게 한개 씩 나오다가(ex: BPM:90) 갑자기 두개가 겹쳐서 나오는 현상이 발생합니다.(ex: BPM:9091) 원인이 무엇인지 알 수 있을까요?
댓글 2
조회수 9,509master님의 댓글
master 작성일
당연히 소스를 분석하셔야하고
소스를 분석하면 오동작 원인을 파악할 수 있습니다.
원인을 잘 찾아보세요
으아아악님의 댓글
으아아악
앱인벤터 코딩 상의 문제일까요? 위의 소스 코드는 질문게시판을 통해 답변해주신 분이 가르쳐 주신 코드라서 제가 아무리 봐도 원인이 위의 코드에는 없는 것 같다는 생각이 들어서요.