Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import controlP5.*;
  2. import processing.serial.*;
  3.  
  4. ControlP5 cp5;
  5. Serial serial;              
  6.  
  7.  
  8. String Mensaje = "";
  9.  
  10. // configuraciĆ³n inicial
  11. void setup() {
  12.  
  13.   serial = new Serial(this, Serial.list()[0], 9600);  
  14.   String puerto = Serial.list()[0];                  
  15.   size(440, 140);
  16.   noStroke();    
  17.  
  18.  
  19.   cp5 = new ControlP5(this);
  20.  
  21.  
  22.   PFont font = createFont("arial", 20);
  23.   textFont(font);
  24.  
  25.   cp5.addTextfield("Mensaje", 20,20, 400,40)
  26.     .setFont(font)
  27.     .setFocus(true)
  28.     .setColor(color(255, 0, 0));
  29.  
  30. }
  31.  
  32.  
  33. void draw()  
  34. {
  35.   background(0xFF444444);  
  36.   text(Mensaje, 20, 100);
  37. }
  38.  
  39.  
  40. void controlEvent(ControlEvent theEvent) {
  41.  
  42.   String nombre = theEvent.getController().getName();
  43.   String texto = theEvent.getController().getStringValue();
  44.  
  45.   println("evento: " + nombre + " / texto: "+texto);
  46.   serial.write(texto);
  47. }