Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

updating text

$
0
0
Hi, new to processing and this might seem obvious but how do i update text? the examples i've seen don't seem to work and involve a kludge of drawing over the text with a rectangle (surely this isn't the answer....)

the application is simple - it writes to a serial port and gets an answer back from an arduino with ambient temp and the time. the text scrolls down the screen with the current code.

import processing.serial.*;

Serial myPort;
String val; 

void setup() 
{
  size(500, 500);
   myPort = new Serial(this, "COM5", 9600);
}

void draw()
{
  frameRate(1);
  textSize(32);
  myPort.write("temp?");
  while ( myPort.available() > 0) {
    val += char(myPort.read());
  }
  println(val);
  if (val != null && val.length() > 9) {
     text(val.substring(9),50,100);
 }
}





Viewing all articles
Browse latest Browse all 1768

Trending Articles