ArDMX provides a simple snippet of C code that you can embed into your own Arduino Project files (no need for additional C/CPP files altought this setup is also supported).
It basically consists of some lines of code in the setup routine, and an Interrupt Service Routine, which is called when new data arrives at the serial port of the Arduino.
The code is heavily based upon a app note by Henn (Henne's Site, German) and was simply adapted for arduino platforms.
As with the other approach by Max Pierson here, there are also two major drawbacks with this one, especially for the unexperienced Arduino/AVR programmer:
This means that the names of the registers and the name of the ISR vector used may differ if you use other hardware or arduino compatible clones. In some cases, it is sufficient to swap the digit contained within the register names (0 for USART0, 1 for USART1,...). When in doubt, the datasheets of the processor in use may help you out. Also, a look into the HardwareSerial.cpp file within your used platform directory can help to gain more information about the ISRs and registers being used. The code below is built to use the first (and only on most platforms) UART.
To avoid a redefinition error upon compile, you have to slightly modify your HardwareSerial.cpp when compiling the DMX receiver code. Don't forget to save the original one before! Now just do a search for "ISR(USARTn_RX_vect)" where n should be replaced by the number of the USART you actually use, e.g. "USART0_RX_vect". When you found the definition, just comment the whole block between the {..} out (it should be about 5 lines long or so).
Besides this drawbacks, you'll also need to have a suitable DMX shield or build a simple DMX receiver circuit on your own. These are mostly based on a 75176 or MAX485 integrated circuit, which is basically a transceiver for RS-485 lines. The RE pin of the MAX485 or 75176 needs to be connected to the RX pin of your arduino, and the IC needs to be powered correctly and have its "Receive Enable" pin set to LOW/GND.
Following variables and defines need to be added to your sketch:
The following code needs to be added to the setup function to configure the serial port correctly and set up serial communication:
The interrupt service routine gets called whenever new data arrives at the USART pin. With the high data rate DMX runs at, this will likely happen very often, so it is crucial to just do the most urgent stuff within that routine, and leave the rest for the main loop.
If all of the above is working correctly, and the RX status LED is blinking happily, you can do the main work with your received DMX values. They are stored in the array called "DmxRxField" and can be used in the main loop, as the ISR does its work on its own and does not need to be called externally.
A simple example for fading a LED according to the DMX value on the first received address might look like this: