Versions Compared

Key

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

...

Um Daten von Processing an DMX zu übergeben nutzen wir ein Arduino als Brücke. Auf das Arduino setzen wir das DMX Shield und programmieren es mit dem folgenden Code:

Code Block
languagecpp
titleArduino DMX Bridge
collapsetrue
// DMX Bridge
//
// Write messages in the form of "2:127\n" to forward
// them to the connect DMX device.

#include <DmxSimple.h>

void setup() {
  Serial.begin(9600);
  DmxSimple.usePin(11);
}

void loop() {
  if(Serial.available() > 0) {
    int channel = Serial.readStringUntil(':').toInt();
    int value = Serial.readStringUntil('\n').toInt();

    Serial.print("set ");
    Serial.print(channel);
    Serial.print(" to ");
    Serial.println(value);
  
    DmxSimple.write(channel, value);
  }
}

...

Im Folgenden ein kleines Beispiel, welches einen RGB Wert an eine DMX Leuchte sendet

Code Block
languagejava
titleProcessing Beispiel
collapsetrue
import processing.serial.*;
Serial port;
 
void setup() {
  background(0);
  size(500, 500);
  frameRate(5);
  
  println(Serial.list());
  port = new Serial(this, "/dev/tty.usbmodem1411", 9600);
  
  sendDMX(1, 0);
  sendDMX(2, 0);
  sendDMX(1, 255);
}
 
void draw(){
  while(port.available() > 0) {
    print(port.readString());
  }
  
  int red = int(map(mouseX, 0, width, 0, 255));
  int green = int(map(mouseY, 0, height, 0, 255));
  
  background(red, green, 0);
  stroke(255);
  text("Red: " + red + " - Green: " + green, 20, 20);
  
  sendDMX(1, red);
  sendDMX(2, green);
  sendDMX(3, 0);
}

void sendDMX(int channel, int value) {
  print(str(channel));
  print(":");
  print(str(value));
  print('\n');
  
  port.write(str(channel));
  port.write(":");
  port.write(str(value));
  port.write('\n');
}

...