I had the same noise issue. Be sure the electrode leads are not laying flat along your body and not near other electronic devices. Also, I changed the processing sketch to clean it up. Kudos to Processing Forum for giving me education on how this works. My processing sketch below. It automates the serial port identification and places code in sections where it belongs. Note the line: xPos = xPos += 2; It adds 2 pixels to each new reading and smooths out the line at 38400. Hope it helps:
import processing.serial.*;
Serial s; // The serial port
int xPos = 1; // horizontal position of the graph
float height_old = 0;
float height_new = 0;
float inByte = 0;
static final int PORT_INDEX = 0, BAUDS = 38400;
String hrNumber = “”;
void setup () {
noLoop();
final String ports = Serial.list();
printArray(ports);
new Serial(this, ports[PORT_INDEX], BAUDS).bufferUntil(ENTER);
size(1900, 400);
}
void serialEvent(final Serial s) {
hrNumber = s.readString().trim();
redraw = true;
println(hrNumber);
}
void draw ()
{
// background(0xff);
if (hrNumber.equals(“!”)) {
stroke(0, 0, 0xff); //Set stroke to blue ( R, G, B)
inByte = 200; // middle of the ADC range (Flat Line)
}
// If the data is good let it through
else {
stroke(0xff, 0, 0); //Set stroke to red ( R, G, B)
inByte = float(hrNumber);
}
//Map and draw the line for new data point
inByte = map(inByte, 0, 1023, 0, height);
height_new = height - inByte;
line(xPos - 1, height_old, xPos, height_new);
height_old = height_new;
// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0xdd);
} else {
// increment the horizontal position:
xPos = xPos += 2;
}
}