[Processing - Arduino] Send multiple data with Serial from Processing to Arduino


hey guys,

i know subject problem recurrent didn't find solution problem.
i want "stream" picture rainbowduino link arduino uno. that, use processing analyse et getpixel rgb value each 8x8 pixel of image. till this, there no matter.

now have send these datas arduino , there matter. didn't manage send data 1 per 1 arduino. it's arduino didn't understand processing data corresponding arduino data.

here code, maybe me newbie problem :)

arduino code :
code: [select]
i#include <rainbowduino.h>

int xwidth;
int yheight;
int color;

void setup(){
  serial.begin(9600);
  rb.init();
}

void loop(){
  if (serial.available() >= 3){
    xwidth = serial.read();
    yheight = serial.read();
    color = serial.read();
    //serial.println (xwidth);
    //serial.println(yheight);
    serial.println(color);
    rb.setpixelxy(xwidth, yheight, color, color, color);   
  } else {
    serial.println("nothing detected");
    (int = 0; < 8; i++){
      for(int j = 0; j < 8; j++){
        rb.setpixelxy(i, j, 0, 0, 0);
      }
    }
  }

   delay(2000);
}


processing code :
code: [select]
import processing.serial.*;

serial myport;
pimage myimage;
int loc = 0;
int xwidth = 0;
int yheight = 0;

void setup(){
 size(8, 8);
 myimage = loadimage("flv.png");
 println(serial.list());
 string portname = serial.list()[2];
 myport = new serial(this, portname, 9600);
}

void draw(){
 image(myimage, 0, 0);

 for(int x = 0; x < myimage.width; x++){
   for(int y = 0; y < myimage.height; y ++){
     loc = y + x*height;
     xwidth = x;
     yheight = y;
     string red = hex((int)red(myimage.get(x,y)));
     string green = hex((int)green(myimage.get(x,y)));
     string blue = hex((int)blue(myimage.get(x,y)));
     //println("a la position ", loc, " r = ", red, ", g : ", green, ", b : ", blue);
     
     myport.write(xwidth);
     println("x: ", xwidth, "sent");
     myport.write(yheight);
     println("y : ", yheight, "sent");
     myport.write(red);
     println("color : ", red, "sent");
     delay(2000);
     
     if (loc == 63){
       println("--- finish ---");
     }
   }
 }
}



thank :) !

edit : fixed code problem. robin !

neither of pieces of code looks arduino code.

...r


Arduino Forum > Using Arduino > Project Guidance > [Processing - Arduino] Send multiple data with Serial from Processing to Arduino


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support