Arduino Code
void loop() {
for (Bcol = 0; Bcol < 15; Bcol++) //loop through cols
{
testcont = Bcol;
SPI.transfer(testcont);
digitalWrite(latchPin, HIGH); //send latch
digitalWrite(latchPin, LOW);
delayMicroseconds(100);
analogReadResolution(10);
//analogRead(analogPin1);
val1 = analogRead(analogPin1);
Serial.println(val1);
//Serial.print("\n");
Serial.flush();
}
Processing Code
void draw() {
if (mySerial.available() > 0 ) {
mySerial.bufferUntil('\n');
String value = mySerial.readString();
value = trim(value);
if ( value != null ) {
output1.println( value );
//output1.print("\n");
output1.flush();
}
}
}
the output text file looks like
591.00
574.00
583.00
606.00
613.00
697.0
0
640.00
613.0
0
603.00
688.0
0
588.00
672.0
0
618.00
618.
00
613.00
601.00
597.00
581.00
646.00
592.00
606.00
Any Idea why there are random newlines?? The data coming from arduino is fine as i checked it in serial monitor Tried doing trim, not doing trim, putting in flush, not doing flush, lowering baudrate, doing mySerial.bufferUntil('\n');
any ideas?