sparkfun / AD8232_Heart_Rate_Monitor

AD8232 Heart Rate Monitor
Other
186 stars 190 forks source link

Processing about AD8232 #17

Closed Crazychaochao closed 5 years ago

Crazychaochao commented 5 years ago

When i use the code of AD8232 -Heart_Rate_Display,it got a problem like this "ArrayIndexOutOfBoundsException: 2" the error code is " myPort = new Serial(this, Serial.list()[2], 9600); " I have try to modify it,for example 0,1,2.my computer COM is 3,but it doesn’t matter

Crazychaochao commented 5 years ago

I don't know if anyone can help me

yongjun94 commented 5 years ago

How about change your code like this? I solved the same problem. using this.


Before code myPort = new Serial(this, Serial.list()[2], 9600);

After code myPort = new Serial(this, Serial.list()[0], 9600);

Crazychaochao commented 5 years ago

Sincerely thanks! I have solved the problem by another way. I will get back to you later on how i solved it ,because now it's got a new problem.So embarrassing! My English is limited,thanks again

------------------ 原始邮件 ------------------ 发件人: "yongjun94"notifications@github.com; 发送时间: 2019年4月12日(星期五) 中午1:54 收件人: "sparkfun/AD8232_Heart_Rate_Monitor"AD8232_Heart_Rate_Monitor@noreply.github.com; 抄送: "邓新潮"838338194@qq.com; "Author"author@noreply.github.com; 主题: Re: [sparkfun/AD8232_Heart_Rate_Monitor] Processing about AD8232(#17)

How about change your code like this? I solved the same problem. using this.

Before code myPort = new Serial(this, Serial.list()[2], 9600);

After code myPort = new Serial(this, Serial.list()[0], 9600);

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Crazychaochao commented 5 years ago

`import processing.serial.*;

Serial myPort; // The serial port int xPos = 1; // horizontal position of the graph float inByte = 0;

int beat_old = 0; int BPM = 0; int beatIndex; float[] beats = new float[500]; // Used to calculate average BPM

void setup () { // set the window size: size(600, 700);

// List all the available serial ports
// if using Processing 2.1 or later, use Serial.printArray()
println(Serial.list());

// I know that the first port in the serial list on my Mac is always my
// Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);

// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');

// set initial background:
background(0);

}

void draw () { // draw the line: stroke(127, 34, 255); line(xPos, height, xPos, height - inByte);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
  xPos = 0;
  background(0);
} else {
  // increment the horizontal position:
  xPos++;
}      

}

void serialEvent (Serial myPort) { // get the ASCII string: String inString = myPort.readStringUntil('\n');

if (inString != null) {
  // trim off any whitespace:
  inString = trim(inString);
  // convert to an int and map to the screen height:
  inByte = float(inString);
  println(inByte);
  inByte = map(inByte, 0, 1023, 0, height);
}

}`

this is the final code

bboyho commented 5 years ago

Hi,

I was updating the tutorial when I noticed your question in the GitHub repo. In case you were wondering, the error that you are seeing in the Processing IDE is probably due to the number of COM ports that are available on your computer:

ArrayIndexOutOfBoundsException: 2

You will need to look at the list of available COM ports and adjust the array number. The case shown in the tutorial shows that the Arduino enumerated on "COM 38" for the author's computer. Counting each COM port from 0 (in terms of programming not in mathematical terms) from left to right. this is listed as element "2".

Available COM ports

As far as the new problem, I am not entirely sure what the issue is since you did not provide enough information on the problem? You only provided your modified code which is missing certain functions that were used in the example code => [ https://github.com/sparkfun/AD8232_Heart_Rate_Monitor/blob/master/Software/Heart_Rate_Display_Processing/Heart_Rate_Display/Heart_Rate_Display.pde ]. You might want to post in one of the following forums for further assistance.

Crazychaochao commented 5 years ago

So sorry to get back so late.I have solved the problem I met,and Thank you very much for your noticed.Sincerely thank you!

------------------ 原始邮件 ------------------ 发件人: "bboyho"notifications@github.com; 发送时间: 2019年4月30日(星期二) 凌晨2:40 收件人: "sparkfun/AD8232_Heart_Rate_Monitor"AD8232_Heart_Rate_Monitor@noreply.github.com; 抄送: "邓新潮"838338194@qq.com;"Author"author@noreply.github.com; 主题: Re: [sparkfun/AD8232_Heart_Rate_Monitor] Processing about AD8232(#17)

Hi,

I was updating the tutorial when I noticed your question in the GitHub repo. In case you were wondering, the error that you are seeing in the Processing IDE is probably due to the number of COM ports that are available on your computer: ArrayIndexOutOfBoundsException: 2
You will need to look at the list of available COM ports and adjust the array number. The case shown in the tutorial shows that the Arduino enumerated on "COM 38" for the author's computer. Counting each COM port from 0 (in terms of programming not in mathematical terms) from left to right. this is listed as element "2".

As far as the new problem, I am not entirely sure what the issue since you did not provide enough information on the problem? You only provided your modified code which is missing certain functions that were used in the example code => [ https://github.com/sparkfun/AD8232_Heart_Rate_Monitor/blob/master/Software/Heart_Rate_Display_Processing/Heart_Rate_Display/Heart_Rate_Display.pde ]. You might want to post in one of the following forums for further assistance.

SparkFun Forums

Processing Forums

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.