Controlling a DMX-Signal

Reading Time: 4 minutes

Party in the disco, a big music festival or a tv show have one thing in common – the need to control their lights. That’s where “Controlling a DMX-Signal” comes into play – a possibility to define which lamp shines at what intensity in red, green, purple or even ochre. But how do they do it?

What is DMX?

DMX (URL)or Digital Multiplex is a standard for digital communication networks and is commonly used (but not limited) in stage lighting and effect. That means by controlling or sending a DMX-Signal you can control one or more lamps, fog machines, lasers, etc. For doing that you would need to understand what data a signal contains and how it is encoded. Luckily there are ready to use libraries and software to use. But generally speaking, DMX uses so-called packets to transmit data in an ordered way. Each packet has a certain structure that the contained data can be recognized and correctly read. But now into the fun part.

As a side note, it may be mentioned to be able to actually test the program you will need a USB-to DMX Adapter and a light that you can control otherwise you will not know if your program is controlling a DMX-Signal

Gathering the libraries

If you search for “DMX library java” you will quite likely won’t find a lot. That is the reason we are going to “build” our own. We will do this by taking a look at dmxP512 (GitHub) which is a library originally written for Processing (Processing). Itself uses two further libraries that are linked in its GitHub. Last but not least JSSC (JSSC) is missing. It stands for Java Simple Serial Connector and enabled our library to communicate with the actual DMX controller.

Create the project

With all libraries downloaded, it’s time to add them to our project. In Eclipse (Eclipse) we do this by modifying the Java Build Path. Right-click on the project select properties and navigate to Java Build Path. Choose the tab Libraries and click the button Add External JARs… Search for the folder where you saved your libraries and mark them all. Save the changes and the libraries should be correctly added. With them, in place, it is almost time to start coding. The only thing missing is a “place” to write code. For this basic project, we will need two classes. The first class is our main class. The second one will be our DMX class. It will “build the bridge” between our project and the libraries and where we control the DMX signals. But let’s begin with the main class.

Writing the code

import dmxP512.DmxP512;
import processing.core.PApplet;

public class Main extends PApplet{

	public static void main(String[] args) {
		DMX dmx = new DMX();
		dmx.setvalue(0, 255);

For that, we have to write the main method and create a new DMX object. For the main class, we are finished. The second class will have a few more lines of code.

import dmxP512.DmxP512;
import processing.core.PApplet;

public class DMX extends PApplet{

	private DmxP512 dmxOutput;
	private int universeSize = 512;
	private final String DMXPRO_PORT = "COM3";// case matters ! on windows port must be upper cased.
	private final int DMXPRO_BAUDRATE = 115000;

First of all, we extend the class PApplet. This is part of the “processing.core” library and is mandatory for our project to function. Then we will define our variables dmxOutput, universeSize, the USB-Port and the rate at which it functions. If for some reason your controller is being correctly addressed there is the point to check which port you are actually using. The constructor will look like this


It initiates the dmxOutput variable with the correct universeSize and a PAplett instance which is the DMX-Class itself. The dmxOutput is assigned its port where the program expects and DMX-Interface is being hooked up.

public DMX() {
	dmxOutput = new DmxP512(this, universeSize, false);

The last method missing is the method that sets the values on the given channel. It should be called whenever a light or an effect has to be changed.

public void setvalue(int channel, int value) {
	dmxOutput.set(channel, value);

It takes a channel and a value as input. The channel is basically like a postal address and is unique within the given DMX-Universe (maximum of 512). The value is an integer ranging from 0 to 255. It defines how bright for example a lamp shines. The method setValue() calls the method set() from the dmxOutput and passes the parameters directly to it.

Now we need to call the method. We can do it anywhere we want but we decided to call it in the main method within the main class. In our case, we set the channel 0 to full brightness

With all of this setup, we can test it. All we need to do is attach an interface to the computer and a lamp to the interface and run our program. Channel 0 should be receiving the signal to shine fully bright.


There are many reasons why the setup doesn’t work. First of all, verify that the lamp actually works. In most cases, the lamp provides a “manual” mode where you can specify via buttons on the lamp itself to shine. The assure yourself that all drivers of the interface are installed and all cables are attached correctly. Maybe choose a different cable or a different USB input. You can also verify that the setup works by using a program like DMXControl so you know if its the connection between computer and interface or not. And then there is always the possibility to change the defined PORT within the code.


Using the general concept of this program you can create many different kinds of programs for controlling a DMX-Signal. For example, you can use it to control a light show, automate your home DMX setup or control DMX-lights by analyzing music and automatically set the light color. There are many options open and many ways to improve and extend this little snippet. If you have more ideas write them down in the comments.

If you have any questions, just ask in the comments, on Instagram or Twitter or simply send us an email.


Leave a Reply

Your email address will not be published. Required fields are marked *