Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //se importan las librerias serial y controlP5
- import processing.serial.*;
- import controlP5.*;
- //se definen las variables
- ControlP5 cp5;
- Textarea myTextarea;
- String textValue = "";
- Serial serie;
- void setup() {
- size(400,400);
- PFont font = createFont("arial",20);
- cp5 = new ControlP5(this);
- cp5.addTextfield("Mensaje")
- .setPosition(20,100)
- .setSize(200,40)
- .setFont(font)
- .setFocus(true)
- .setColor(color(255,250,200))
- ;
- serie = new Serial(this, Serial.list()[1], 9600);
- textFont(font);
- }
- void draw() {
- background(0);
- fill(255);
- //text(cp5.get(Textfield.class,"input").getText(), 360,130);
- text(textValue, 360,180);
- }
- /*public void clear() {
- cp5.get(Textfield.class,"input").clear();
- }*/
- void controlEvent(ControlEvent theEvent) {
- //se captura el evento y se envia por el puerto serial
- if(theEvent.isAssignableFrom(Textfield.class)) {
- println(""+theEvent.getStringValue());
- serie.write(""+theEvent.getStringValue() );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement