Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import processing.serial.*;
  2. Serial port;
  3. int valor;
  4. PFont f;
  5.  
  6. void setup(){
  7.  
  8.   println(Serial.list());
  9.   port = new Serial(this, Serial.list()[0], 9600);
  10.    size(430,300);//tamaƱo de la ventana
  11.   background(128); //color de fondo
  12.   frameRate(1000);
  13.  
  14.   f = loadFont("FonCar.vlw"); //carga la letra
  15.  
  16. }
  17.  
  18. void draw()
  19. {
  20.  
  21.   while (port.available() > 0) {
  22.     String cadena = "00" + port.readString();  
  23.    valor = int(cadena.substring(0,cadena.length()-2));
  24.     println(cadena + ":" + valor);// probar el  valor de entrada .
  25.    textFont(f,18);  // aplica la letra
  26.      background(128); //color de fondo
  27.     text("led :  = " + valor, 105, 185);//imprime el led que esta encendido
  28. }
  29.  
  30. fill(0,0,0); // color  negro
  31.      /* se crean las elipses */
  32.      ellipse(50,100,80,80);
  33.      ellipse(130,100,80,80);
  34.      ellipse(210,100,80,80);
  35.      ellipse(290,100,80,80);
  36.      ellipse(370,100,80,80);
  37.  
  38.  
  39.  
  40.  if (valor==2 ) //condiciones
  41.   {
  42.     fill(255,255,0); // amarillo
  43.     ellipse(50,100,80,80);
  44.   }
  45.  
  46.   if (valor==3)
  47.   {
  48.     fill(0,255,0);// verde
  49.     ellipse(130,100,80,80);
  50.   }
  51.  
  52.   if (valor==4)
  53.   {
  54.     fill(255,255,0); // amarillo
  55.    ellipse(210,100,80,80);
  56.  
  57.   }
  58.  
  59.   if (valor==5)
  60.   {
  61.     fill(0,255,0);// verde
  62.    ellipse(290,100,80,80);
  63.   }
  64.  
  65.   if (valor==6)
  66.   {
  67.     fill(255,0,0);// rojo
  68.     ellipse(370,100,80,80);
  69.   }
  70.  
  71. }