Connecting to 32x32LED matrix

edited March 2016 in Arduino

HI, I have a 32x32 array in Processing with some arbitrary functions. How do I display what I created in Processing on my 32x32 LED RGB matrix via the arduino?

The Processing code is show below:

`

int a,sCol,b;
int red = color(255,0,0);
int green = color(0,255,0);
int blue = color(0,0,255);
int yellow = color(255,247,3);
int cols = 32;
int rows = 32;
MyRect[][] grid = new MyRect[cols][rows];

void setup() {
  size (1000,800);

  smooth();
  for (int i =0; i < cols; i++) {
    for ( int j = 0; j< rows; j++) {
      grid[i][j] = new MyRect (i*21+20,j*21+20,20,20,i,j);
    }
  }


}

void draw() {
  background(#BCBCB8);







  noFill();
  stroke(0);
  rect(780,10,190,600);


  String s = "  Colour Pallet"; 
  stroke(#FFFFFC); 
  fill(#9625E3);
  textSize(20); 
  text( s, 800,40);

  String s1 = "Selected Colour"; 
  stroke(#FFFFFC); 
  fill(#9625E3);
  textSize(20); 
  text( s1, 800,330);


   String z = "LED property controller";
   stroke(#FFFFFC);
   fill(#9625E3);
   textSize(25);
   text( z, 220,720);





  fill(red);//(0,0,255);
  rect(850,70,40,40);
  fill(green);//(0,255,0);
  rect(850,120,40,40);
  fill(blue);//(255,0,0);
  rect(850,180,40,40);
  fill(yellow);
  rect(850,240,40,40);
  fill(sCol);
  rect(850,350,40,90);

  for (int i = 0; i < cols; i++) {
    for ( int j = 0; j< rows; j++) {
      grid[i][j].draw();
    }
  }
}

void mousePressed() {
  if (mouseX > 365) {
    a = get(mouseX,mouseY);
    if (a == red || a == green || a == blue || a == yellow) sCol = a;
  }


}

class MyRect {
  float x, y, wide, high, bi, bj;
  color b;

  MyRect(float x, float y, float wide, float high, float bi, float bj) {
    this.x = x;
    this.y = y;
    this.wide = wide;
    this.high = high;
    this.bi = bi;// column number
    this.bj = bj;// row number
    b = color(0);
  }

  void draw() {
    if(over()) {
      stroke(255,0,255);
      if(mousePressed) {
        if (mouseButton == LEFT) { b = sCol; }
        if (mouseButton == RIGHT) { b = color(0); }
      }
    } else { stroke(255); }
    fill(b);
    rect(x, y, wide, high);
  }

  boolean over() {
    if (mouseX >= x && mouseX <= x+wide &&
      mouseY >= y && mouseY <= y+high) {
      return true;
    }
    return false;
  }
}
`

for anyone wanting to test it, left click to select colour, right to remove.

Tagged:
Sign In or Register to comment.