Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleBeispiel RGB über DMX Senden
collapsetrue
  import processing.serial.*;  // Import the Processing Serial Library for communicating with arduino
Serial dmxPort;               // The used Serial Port

int[][] dmxValues; //First dimension = number of DMX channels //Second dimension = channel, value
int amountOfDMXChannels = 3;

void setup()
{
  background(0);
  size(500, 500);
  println(Serial.list()); // Prints the list of serial available devices (Arduino should be on top of the list)
  dmxPort = new Serial(this, Serial.list()[Serial.list().length-1], 9600); // Open a new port and connect with Arduino at 9600 baud

  dmxValues = new int[amountOfDMXChannels][2];
  dmxValues[0][0] = 0;
  dmxValues[1][0] = 1;
  dmxValues[2][0] = 2;
}

void draw()
{
  background(0);
  color c = color(map(mouseX,0,width,0,255),map(mouseY,0,height,0,255),0);
  text("R: "+red(c)+"\t G: "+green(c)+"\t B: "+blue(c), 20, 20);
  dmxValues[0][1] = int(red(c));
  dmxValues[1][1] = int(green(c));
  dmxValues[2][1] = int(blue(c));
  sendDMX(dmxValues);
}

void sendDMX(int valuesToSend[][])
{
  for (int i=0; i<valuesToSend.length; i++)
  {
    dmxPort.write(str(valuesToSend[i][0]));
    dmxPort.write(",");
    dmxPort.write(str(valuesToSend[i][1]));
    dmxPort.write("\n");
  }
}

Einstellungen an den DMX Empfängern (Leuchten, Scanner usw.)

...