DMX512 is kinda cool. You often find it used in theatre. But these days it lurks in council public lighting systems and the occasional household Christmas display. DMX can control lights, fog machines, relays and my personal favorite, the DMX flame thrower.

A photo of a DMX controlled flame thrower puffing fire.

When DMX512 was first developed in 1986, the original controllers were big, bulky and expensive. These days a Raspberry Pi can control DMX devices.

You will also need one of the following USB DMX controllers to go with your Raspberry Pi:

Both of these devices use FTDI drivers to connect to the Raspberry Pi. So they should work straight out of the box with Raspbian, but the driver installation instructions are here if you get stuck.

After you have connected the DMX controller to the Raspberry Pi via USB, you can test the connection with the following command:

	$ dmesg | grep FTDI

If everything is working, you should see something like the following:

	[    7.893865] usb 1-1.4: FTDI USB Serial Device converter now attached to ttyUSB2

Take note of the ttyUSB2 part. Your trailing number might be different, but that is the address to use when programming your DMX controller.

From here you will also need some three-pin XLR connectors to hook up your DMX controller to whatever device you want to program.

The programming language Go and the DMX library from Akualab can program your controller. The first step is to connect to the DMX controller via that ttyUSB address you noted earlier:

	// Connect to the DMX controller.
	dmx, e := dmx.NewDMXConnection("/dev/ttyUSB2")
	if e != nil {
		log.Printf("ERROR: Unable to connect to DMX512 interface.")
	defer dmx.Close()

Now in the following example, I was controlling a fog machine. The fogger was on channel one and this particular model took a value between 0 and 127 for controlling the fog intensity. With 0 being no fog (turning the fogger off) and 127 set the machine to output a dense plume of fog.

	dmx.SetChannel(1, byte(127))

	// Output fog for 1 second.
	st := time.NewTimer(time.Millisecond * 1000).C

	// Turn off the fog machine.
	dmx.SetChannel(1, 0)