BASIC4MCU | 질문게시판 | 외국에서 프로젝트중인데 코드해석이 안되서 질문드립니다ㅠ
페이지 정보
작성자 Hyungma 작성일2019-04-03 07:31 조회10,640회 댓글4건본문
코드를 아무리 봐도 이해가 안됩니다ㅠㅠ 설명과 주석 달아주시면 감사하겠습니다!#include <LiquidCrystal.h> //constants fo the number of rows and columns in the LCD#include <Wire.h>#include "MAX30100_PulseOximeter.h"#define REPORTING_PERIOD_MS 1000//Import processing.serial.*;Serial SerialPort;PrintWriter output;//LCDconst int numRows = 2;const int numCols = 16; //constants for the pins used to connect LCD to Arduinoconst int d4 = 7;const int d5 = 8;const int d6 = 9;const int d7 =10;const int rs = 11;const int enable = 12;// initialize the library with the numbers of the interface pinsLiquidCrystal lcd (rs, enable, d4, d5, d6, d7);//// PulseOximeter is the higher level interface to the sensor// it offers:// * beat detection reporting// * heart rate calculation// * SpO2 (oxidation level) calculationPulseOximeter pox;uint32_t tsLastReport = 0;String portName = Serial.list()[0];SerialPort = new Serial (this, portName, 115200);output = createWriter("D:\DEVELOPMENT PROJECT\New folder\new data.txt");}void draw(){if(SerialPort.available() >0){String value = SerialPort.readString();if (value != null) {//save dataoutput.println(value);}}}void keyPressed(){output.flush();output.close();exit();}void setup(){Serial.begin(115200);//LCDlcd.begin(numCols, numRows);lcd.print("Heart rate: "); // print a message to the LCD.// set the cursor to column 0, line 1// (note : line 1 is the second row, since counting begins with 0) :lcd.setCursor(0, 1);lcd.print("SpO2: ");//Serial.print("Initializing pulse oximeter..");// Initialize the PulseOximeter instance// Failures are generally due to an improper I2C wiring, missing power supply// or wrong target chipif (!pox.begin()) {Serial.println("FAILED");for(;;);} else {Serial.println("SUCCESS");}// The default current for the IR LED is 50mA and it could be changed// by uncommenting the following line. Check MAX30100_Registers.h for all the// available options.// pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);// Register a callback for the beat detection// pox.setOnBeatDetectedCallback(onBeatDetected);}void loop(){// Make sure to call update as fast as possiblepox.update();// Asynchronously dump heart rate and oxidation levels to the serial// For both, a value of 0 means "invalid"if (millis() - tsLastReport > REPORTING_PERIOD_MS) {lcd.setCursor(11,0);lcd.print(pox.getHeartRate());lcd.setCursor(11,1);lcd.print(pox.getSpO2());lcd.setCursor(13,1);lcd.print("%");Serial.print("Heart rate:");Serial.print(pox.getHeartRate());Serial.print("bpm / SpO2:");Serial.print(pox.getSpO2());Serial.println("%");tsLastReport = millis();}}
댓글 4
조회수 10,640master님의 댓글
master 작성일
하나도 모른다고 적으면 c언어 문법부터 가르쳐 달라는 뜻이 됩니다.
모르는 것만 하나씩 질문을 하셔야합니다.
master님의 댓글
master 작성일
https://www.arduino.cc/en/Reference/LiquidCrystal
위 레퍼런스를 참고하시고요
이 분야는 직접 동작시켜야지 이해가 되는 경우가 대부분입니다.
먼저 동작시키고
여러가지 예제를 동작시키다보면 이해가 안되던 것들이 저절로 이해가 되는 것이 상당히 많습니다.
master님의 댓글
master 작성일
https://www.google.com/search?q=%EC%95%84%EB%91%90%EC%9D%B4%EB%85%B8+MAX30100_PulseOximeter&pws=0&gl=us&gws_rd=cr
heart rate sensor도 웹검색에 충분한 자료가 나와있습니다.
master님의 댓글
master 작성일
https://www.google.com/search?pws=0&gl=us&ei=HzakXJ-REcLnwQPR6J_QCA&q=%EC%95%84%EB%91%90%EC%9D%B4%EB%85%B8+createWriter&oq=%EC%95%84%EB%91%90%EC%9D%B4%EB%85%B8+createWriter&gs_l=psy-ab.12...589483.589483..590357...0.0..0.130.130.0j1......0....2j1..gws-wiz.zkLLszLaZQM
프로세싱하고 연동하고 있나보죠?
프로세싱 코드하고 아두이노 코드가 섞여있는 것 같습니다.