Receive DMX-512 with an Arduino
Part I: ProloguePart II: Instructions

Shiny and new out of the box!
Prologue: For Christmas, I received an Arduino. If you’re not familiar with them, they’re like a little computer with a lot of pins to which you can connect outputs like LEDs, servos, relays, triacs, or anything you’d want to control, as well as photosensors, switches, anything you’d want to take an input from. You write your program in the easy-to-learn Arduino environment, upload it to the Arduino board, and it’ll run your program automagically. I’m not a programmer, but less than an hour after taking it out of the box I had it blinking an LED for me. Buy one, they’re perfect for all of us who are trying to create some Theater Magic with no money or hope of getting any.
Well, Almost Perfect. There’s been a way to send DMX with an Arduino for awhile, but when I started poking around for DMX reception code, I came up with zilch. If you’re already savvy with microcontrollers and assembly code and avrdude and whatever-the-fuck-else, you probably know about this solution. Me, I look at assembly code and I just hear a dull screaming in my head, nevermind all that other stuff that I don’t know how to do either.
So I figured that a great first project would be to remedy this situation, and write a program to receive DMX on the Arduino platform. In the way of all Works in this Vale of Tears, this ended up being much more difficult and taking much longer than I initially anticipated. But eventually I figured it all out, and so here it is!
Features:
- In-the-field addressing from 1 to 512 via two tact switches (works with the previously released I/O Shield, here).
- Address is stored in non-volatile EEPROM, so it is retained when power is lost to the Arduino.
- Addressing hardware allows full use of the pins.
- Number of addresses to receive is configurable.
- Works with controllers that send less than the full 512 address set.
- Break detection is done correctly by detecting a Low value of >88μS per ANSI E1.11-2008, rather than the frame error hack used by many devices.
- Uses interrupt-based subroutines to eliminate processor-load related timing problems.
- If the DMX data signal is lost, the Arduino will maintain the current state until new values are received.
- The reception and user code run sequentially rather than at the same time, so they won’t interfere with each others’ timing.
Continue to Page 2 for Download and Instructions…
Go to Section:


September 27th, 2011 at 6:11 am
i can confirm that the shield must be unplugged to upload code. on my boards i put a jumper on pin0, or use a 10way dip switch for adressing and use the extra pin to enable/disable the 485 transciever.
to the people who requested my modifications to Max’s original (and fantastic) code:
i have recently updated my code for a new project, i’ll post it on my website in the next few weeks.
now it can use adresses 1- 511,
3 channels of pwm with p-channel mosfets
and 3 240v relays!
Max, i have one problem though, if i disconect the dmx cable, it receives random gibberish.(not before connecting though…)
ewan.
does mark after break detection only trip once?
January 3rd, 2012 at 6:53 am
Hi
is there a way to get this working in Arduino 1.0 I have got some trouble to get this working I just wan´t to get my Arduino Bord to recive DMX. There isn´t any other solution on that I think. I think it´s the crappy HardwareSerial.cpp thing that I stuck on
Many thanks for your Help.
Sebastian, Hannover Germany
January 3rd, 2012 at 12:57 pm
Hi Sebastian,
I’m sure this is possible, my prior experience has been that the HardwareSerial.cpp changes little if at all from release to release, so you just need to find the lines that conflict and comment them out. But I’ve got so many other projects in the works these days that I wouldn’t expect I’d get to this any time soon. In the meantime, unless there’s some new aspect of the software that you need, you could always use a prior tested release to compile.
Max
January 3rd, 2012 at 3:04 pm
Many Thanks,
I hav got the clue by using the 0021 release of Arduino no errors while compiling. The new HardwareSerial.cpp seems to be completely different to me 200 lines to 400 lines … I now ran into other cruxes – I opend the three files on arduino and it seems to me that only one sketch is uploading to the board. Maybe you could give me a hint …
January 4th, 2012 at 1:03 am
Hi again,
it´s working now ! Thank You for your great job ! I testet it with my Open DMX USB with some kind of DMX Software. Some of my desks dosn´t working in fact they send 512 chans.
MA 12/02 / grandMAUltraLight / LeapFrog 48
January 10th, 2012 at 10:32 am
Sebastian H: any chance you could post your solution to the 1.0 dilema? I’m having the same problem.
January 12th, 2012 at 7:01 am
Just a quick question: will this work on the Mega so I can use the other serial ports to communicate over RS232?
January 17th, 2012 at 5:26 am
@Bennage
Hi, I just use the older Release Version 0021
January 20th, 2012 at 8:22 am
i could not find the .cpp so just to anyone that have the same problem i found mine under \arduino-0022\hardware\arduino\cores\arduino
February 3rd, 2012 at 3:00 pm
Hi, I have a little problem with the DMX code. When I connect the board to the PC through a usb-DMX cable and use the DMX program it works fine but when I connect it to a 6 ch DMX pannel the channels are overlaping and the period between channels fluctuates.
The signal from the PC doesn’t do that.
So the question is how I can make it work with that DMX 6 ch pannel?
February 3rd, 2012 at 3:03 pm
I forgot to mention! Very good job! and Thanks! for the code.
February 4th, 2012 at 1:33 pm
Christoffer, I think i am just being very dumb right now, but I don’t know how to access any of these files, my computer doesn’t seem to think they exist, any tips on how to get to them?