Hola a todos, tengo el codigo ejemplo del sensor de aire para arduino de e-health y quiero graficar la señal obtenida por el monitor serial en processing, ya realice el codigo en processing pero registra un error y no grafica nada, agradeceria la colaboracion del foro. PD: soy nuevo programando en ambos software.
Codigo arduino.
#include <eHealth.h>
void setup() {
Serial.begin(9600);
}
void loop() {
int air = eHealth.getAirFlow();
eHealth.airFlowWave(air);
}
Codigo processing.
import processing.serial.*;
Serial myPort;
int xPos = 1;
int lastxPos = 1;
int lastheight = 0;
String val;
void setup()
{
size (400,400);
myPort = new Serial(this, Serial.list()[0], 9600);
background (0);
}
void draw()
{
if (myPort.available()>0)
{
val = myPort.readStringUntil('\n');
}
val = trim(val);
float inByte = float(val);
stroke (127,34,255);
strokeWeight(4);
line(lastxPos, lastheight, xPos, height - inByte);
lastxPos = xPos;
lastheight = int(height - inByte);
if (xPos >= width)
{
lastxPos = 0;
background(0);
}
else
{
xPos++;
}
}