Advertisement
Josueco

lab10_pro

May 28th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. //se importan las librerias serial y controlP5
  2. import processing.serial.*;
  3. import controlP5.*;
  4.  
  5. //se definen las variables
  6. ControlP5 cp5;
  7. Textarea myTextarea;
  8. String textValue = "";
  9. Serial serie;
  10.  
  11. void setup() {
  12.   size(400,400);
  13.  
  14.   PFont font = createFont("arial",20);
  15.  
  16.   cp5 = new ControlP5(this);
  17.  
  18.   cp5.addTextfield("Mensaje")
  19.      .setPosition(20,100)
  20.      .setSize(200,40)
  21.      .setFont(font)
  22.      .setFocus(true)
  23.      .setColor(color(255,250,200))
  24.      ;
  25.                
  26.  
  27.      serie = new Serial(this, Serial.list()[1], 9600);
  28.      textFont(font);
  29. }
  30.  
  31. void draw() {
  32.   background(0);
  33.   fill(255);
  34.   //text(cp5.get(Textfield.class,"input").getText(), 360,130);
  35.   text(textValue, 360,180);
  36. }
  37.  
  38. /*public void clear() {
  39.   cp5.get(Textfield.class,"input").clear();
  40. }*/
  41.  
  42. void controlEvent(ControlEvent theEvent) {
  43. //se captura el evento y se envia por el puerto serial
  44.   if(theEvent.isAssignableFrom(Textfield.class)) {
  45.     println(""+theEvent.getStringValue());
  46.     serie.write(""+theEvent.getStringValue()  );
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement