Text function issue

edited February 2017 in Arduino

Hi, I'm currently stuck with a bit of code and i am relatively new to processing. I'm currently sending across a data from an arduino with a Bluetooth device to my laptop, this works fine but and the correct value is being sent and received. The issue is that the character is displayed for a too small amount of time before it disappear, is there a simple way to stop this? also the text box displays NULL for the first letter can this also be edited?

import processing.serial.*;

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

void setup() {
  size(400, 400);
  textSize(20);

  String portName = Serial.list()[0]; 
  myPort = new Serial(this, portName, 9600);
}

void draw() {

  background(51);

  if (myPort.available() > 0) { 
    val = myPort.readString();         
    if (val == null) {
      println("");  // This line is printed
    } 
    else {
      if(val !="") {
        sa3 = sa3 + val;
        text(sa3, 10, 100);
      }
    }
  } 
  println(sa3); 
}

Thanks :)

Answers

Sign In or Register to comment.