We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi.
I'm trying to make a pulse oximeter with Arduino UNO.
I've made basic electronic circuit using SFH-4557(850nm) LED, MTE6066N1-UR (650nm) LED, and OPT101P Photosensor. I think it works well.
Objective: The arduino sends two data(650nm, 850nm sensor values) respectively, and Processing receives these data and assign to different array variables and plotting...; (Sorry for poor English..)
But when I using processing 2.2.1, I've found out that my graph goes from right to left, and it looks like blinking boxes!!... I've used Tom Igoe's code in arduino homepage. I just modified it a little..
My code are here.. What's wrong with my code? Is this a frame rate problem? I don't understand what problem makes me crazy...
Please help..
import processing.serial.*;
Serial myPort;
int xPos = 1;
PFont f;
//Values of seperate LEDs
float[] S850Val = new float[600];
float[] S650Val = new float[600];
void setup() {
size(600, 600);
frameRate(60);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil('\n');
background(0);
f = createFont("Arial", 32, true);
}
void draw() {
String inString = myPort.readStringUntil('\n');
if (inString != null) {
inString = trim(inString);
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, 300);
//assign Sensor 850nm, Sensor650
for (int i = 0; i < 600; i++){
if (inByte < 200.0) {
S850Val[i] = inByte;
} else {
S650Val[i] = inByte;
}
}
//drawing both sensor's data
for (int j = 0; j < 600; j++){
if(xPos >= width){
xPos = 0;
background(0);
}else{
xPos++;}
//Printing legend..
textFont(f);
fill(255);
text("650nm", 10, 32);
text("850nm", 10, 332);
//Drawing graph
stroke(255);
line(xPos, 300, xPos, (300 - S650Val[j]) + 100);
line(xPos, 600, xPos, (600 - (S850Val[j] * 10) - 100));
//Test print (Temporary serial output)
println(S650Val[j]);
println(S850Val[j]);
}
}
}
Answers
Hi wondering if you solved this problem? Currently trying to plot to values on the same graph as well