Você está na página 1de 1

/***********************************************************/

/*** PROGRAMA BASE PARA COMUNICACIÓN SERIE CON ARDUINO ****/


/*** Para trabajar con "un solo puerto" ***/
/*** SE DEFINE EL PUERTO - USO DE PARÁMETRO ***/
/*** Instrucciones SIN ACLARACIONES ***/
/***********************************************************/

import processing.serial.*;
Serial MiPuerto;
float Datos;

void setup (){


printArray (Serial.list ());
MiPuerto = new Serial(this, Serial.list()[1], 9600);
MiPuerto.bufferUntil('\n');
}

void draw (){


/* se escriben instrucciones */
println (Datos); // a modo de prueba
noLoop();
}

void serialEvent (Serial P) {

P=MiPuerto;
String DatosLeidos;
DatosLeidos=MiPuerto.readString();
MiPuerto.bufferUntil('\n');

if (DatosLeidos != null) {

DatosLeidos = trim (DatosLeidos);


Datos = float(DatosLeidos);
loop(); //redraw ();
}
}

Você também pode gostar