Processing Software Serial Store issue

Hi,I am using the Processing software to display letters and numbers sent over Bluetooth from an arduino device, I am trying to display each letter next to each other in the processing software window, i am sending data via the the serial port. i can get it to display one letter at a time using program 1, but cant find a away of displaying more than one character at a time, slightly lost for ideas.

code is as follows

import processing.serial.*;

Serial myPort;  // Create object from Serial class
String val;



void setup()
{
  size(400, 400);
  textSize(20);
  
  String portName = Serial.list()[0]; 
  myPort = new Serial(this, portName, 9600);

}

void draw()
{
    background(51);
   
  text("Hello! Ready For Input:", 10, 60);
  
  if ( myPort.available() > 0) 
  { 
  
  val = myPort.readStringUntil('\n');         
  
  if (val == null) {
  println("");  // This line is printed
} 
  else {
  text(val, 10, 100);
  println("");  // This line is not printed

  }
 } 
 println(val); 
}
  println("");  // This line is printed
}
  else {
  text(val, 10, 100);
  println("");  // This line is not printed

How do you know which println() statement is printing the carriage return/line feed?

Where is the Arduino code?

Hi, iv attached the code, its a large code but effectively just sends a A,B,C… when selected by an attach interrupt, then sent.

Ell.h (6.39 KB)

Vector.h (1.62 KB)

arduinomostr.ino (13.7 KB)

LedControl.h (7.01 KB)

I got this far reading your code:

attachInterrupt(digitalPinToInterrupt(2), ButtonClick,LOW);

void ButtonClick(){
 
  Serial.println(AlphaNum);
  
  delay(100);
}

Before you start using interrupts, you MUST understand what you can, and can not do, in an interrupt service routine.

Serial IO is not a good idea. delay() is an absolute NO-NO.

i can remove the delay, the code works in sending the letter across that is selected and is displayed in processing program, i just cant think of way to display two+ letters.

i just cant think of way to display two+ letters.

I don’t understand the problem. If the Arduino sends “One”, and Processing reads the data up to the , val should contain “One”.

Perhaps you need to shut down Processing, and open the Serial Monitor app, instead, to see what is actually being sent.

The draw() function is not the place to read serial data. That should be done using the serialEvent() callback, which gets called when there is serial data to be read. You should be using Serial::bufferUntil() in setup, to define when the callback should be triggered.

Thanks for the response, the code works find in sending and displaying a character that has been sent from the Arduino. The issue is that i cannot figure out way of displaying two characters, as the defined variable var gets over written each time, as the code loops round.