Summary of Small Arduino DMX controller
This article shows how to build a compact Arduino-based DMX512 controller (six analog channels plus 12 pushbutton binary channels) to operate a smoke machine or for testing. It uses inexpensive parts, an Arduino (Uno/Mega/Nano with minor changes), potentiometers, pushbuttons with internal pullups, and the Arduino four universes DMX 512 library. The code reads six analog inputs (10-bit scaled to 8-bit) and multiple digital inputs to populate DMX channels. Known issues and tips include selecting the correct board, Nano USART limits, and reinstalling the DMX shield after programming.
Parts used in the Small Arduino DMX controller:
- Arduino board (Uno, Mega, Nano or similar)
- DMX shield
- Potentiometers (6)
- Pushbuttons (up to 12)
- Wiring/jumper cables
- Power supply for Arduino and DMX
- Computer with Arduino IDE
- Arduino four universes DMX 512 library (lib_dmx)
- Fritzing for wiring sketches (optional)
DMX512 is the control signal used by stage lights, dimmers and smoke machines. This project turns an Arduino into a small DMX controller: six potentiometers set channels 1 to 6 from 0 to 255, and twelve push buttons switch channels 7 to 18 fully on or off. It is handy for running a smoke machine or testing a fixture without a lighting desk.
Datasheet verified by us. The serial-port facts on this page (250 kbaud at 16 MHz, two stop bits, the transmit pin) were checked against the ATmega328P datasheet. The DMX signal levels, connector wiring and timing are standard DMX512 and RS-485 practice. We have not compiled or run the sketch, because it needs the DMX library that this page links to and we did not install it, so treat the sketch as untested and check it with your own setup.
- DMX512 is a one-way serial signal at 250,000 baud with 8 data bits and 2 stop bits, sent over RS-485 cable. An Arduino’s serial port can make it, and an RS-485 driver (usually on a DMX shield) puts it on the cable.
- Six analog inputs (A0 to A5) become channels 1 to 6; twelve buttons on pins 2 to 13 become channels 7 to 18.
- The potentiometer readings (0 to 1023) are shifted right by two bits to give DMX values from 0 to 255.
- The DMX output uses the Arduino’s hardware serial port 0, which is shared with USB. Remove the DMX shield while uploading.
How DMX512 works
A DMX controller sends the same block of up to 512 channel values over and over, about 44 times a second if all 512 are sent. Each fixture is set to a start address and listens to its own channels. The data is serial, one byte per channel, at 250,000 bits per second. Each byte has 1 start bit, 8 data bits and 2 stop bits. A frame begins with a long low “break” followed by a start byte of 0, then the channel values.
The ATmega328P serial port (USART) can produce this format. It supports 5 to 9 data bits and 1 or 2 stop bits (datasheet p. 183), and at 16 MHz a setting of 3 in the baud register gives exactly 250 kbaud, with a 0.0 per cent error (datasheet p. 199). The transmit pin is PD1, which is Arduino pin 1 (datasheet p. 97).
| DMX512 item | Value |
|---|---|
| Data rate | 250,000 bit/s (4 µs per bit) |
| Frame format | 1 start bit, 8 data bits, 2 stop bits, no parity |
| Channels per universe | Up to 512 |
| Value range | 0 to 255 per channel |
| Cable | Shielded twisted pair, RS-485 levels |
What you need
DMX shield with an RS-485 driver and XLR socket
6 potentiometers (10 kΩ)
12 momentary push buttons
Breadboard or panel, wire
DMX cable and a DMX device to control
Install the “Arduino four universes DMX 512” library (lib_dmx.h) from deskontrol.net into your Arduino libraries folder. It provides ArduinoDmx0 for the first serial port and more on boards with several (Mega 2560).
Wiring the controls
| Control | Arduino pin | DMX channel | Behaviour |
|---|---|---|---|
| Potentiometers 1 to 6 (centre pin) | A0 to A5 | 1 to 6 | 0 to 255, following the knob |
| Push buttons 1 to 12 | Pins 2 to 13 | 7 to 18 | 255 while pressed, 0 when released |
- Wire each potentiometer’s outer pins to 5V and GND and its centre pin to the analog input.
- Wire each button between its pin and GND. The sketch turns on the Arduino’s internal pull-up resistor, so no external resistor is needed. A pressed button reads LOW.
- Plug the DMX shield on top of the Arduino, following the shield’s documentation for the XLR connector and any direction switch.
The sketch
setup() turns on the pull-ups on pins 2 to 13, then starts universe 0 in standard DMX512 mode, with the first channel at address 1 and 100 channels in each frame. loop() copies the six analog readings and twelve button states into the transmit buffer; the library sends it continuously in the background.
// duino4projects.com
// Small DMX512 controller: 6 potentiometers (A0 to A5) -> DMX channels 1 to 6,
// 12 push buttons (pins 2 to 13) -> DMX channels 7 to 18 (255 while pressed, 0 when released).
// Needs the "Arduino four universes DMX 512" library (lib_dmx.h) from deskontrol.net.
#include <lib_dmx.h>
#define DMX512 (0) // 250 kbaud, standard DMX512
void setup() {
for (int i = 2; i <= 13; i++) {
pinMode(i, INPUT_PULLUP); // pressed = LOW, released = HIGH
}
ArduinoDmx0.set_tx_address(1); // first DMX channel to send
ArduinoDmx0.set_tx_channels(100); // number of channels in each frame
ArduinoDmx0.init_tx(DMX512); // universe 0 on USART0, standard mode
}
void loop() {
for (int ch = 0; ch < 6; ch++) {
ArduinoDmx0.TxBuffer[ch] = scale(analogRead(ch)); // channels 1 to 6
}
for (int b = 0; b < 12; b++) {
ArduinoDmx0.TxBuffer[6 + b] = (digitalRead(2 + b) == LOW) ? 255 : 0; // channels 7 to 18
}
}
uint8_t scale(uint16_t value) { // 10-bit reading (0 to 1023) to 8-bit DMX value (0 to 255)
if (value > 1023) value = 1023;
return value >> 2;
}
scale() shifts the 10-bit reading right by two bits, which divides it by 4. A reading of 1023 becomes 255 and 0 stays 0. To add more controls, extend the loops and keep the channel count (here 100) at least as large as the highest channel you use.
Using the controller
- Set your fixture or smoke machine to DMX mode and to a start address, for example 1.
- Connect the DMX cable from the shield’s output to the fixture’s input.
- Move potentiometer 1. The fixture’s first channel (often dimmer or output level) follows it.
- Press button 1 to send 255 on channel 7 for as long as it is held. For a smoke machine, set its start address so that the fire channel is one of channels 7 to 18.
When something does not work
| Symptom | Likely cause | Fix |
|---|---|---|
| “ArduinoDmxN was not declared in this scope” | The wrong board is selected | Choose your board under Tools, Board. Universes 1 to 3 exist only on boards with more than one serial port. |
| Only ArduinoDmx0 works | You are using a Nano or Uno with a single serial port | Use ArduinoDmx0, or a Mega 2560 for more universes. |
| Upload fails or hangs | The DMX shield is still fitted | Remove it, upload, and refit it. |
| Fixture does not respond | Wrong DMX address or mode on the fixture, or the cable polarity is wrong | Check the fixture’s address and mode, and try a different DMX cable. |
| Values jump when a knob is still | Electrical noise on the analog inputs | Add a 100 nF capacitor from each wiper to GND, or average a few readings. |
Project variants: DMX with Arduino
- DMX Ardweeny Node using Arduino: a DMX Ardweeny node
- Arduino DMX shield for Christmas projects: an Arduino DMX shield
- DMX Effect Controller: a DMX effect controller
Related projects: RS-485 and lighting control
- Android Arduino Communication through Modbus and Rs485: Android and Arduino communication over RS-485 Modbus
- Security Check RFID System Based on Arduino and RS485 Data Bus: an RFID security system on an RS-485 bus
- RS485 – ARDUINO AND INDUSTRIAL DISTANCE SENSOR: an industrial distance sensor over RS-485
Quick answers
Check your own build
Before connecting a stage fixture, test with a single cheap DMX device. Move each potentiometer through its range and confirm the matching channel changes smoothly from 0 to 255, then press each button and confirm its channel jumps to 255 and back. Check the fixture’s address first if nothing happens.
Project resources and downloads
- 📄 ATmega328P datasheet (Microchip DS40002061B)
PDF, 653 pages, about 33 MB. Frame format (page 183), baud rate table (page 199), serial pins (page 97). - 📦 Arduino four universes DMX 512 library
Web page with download. The library the sketch needs. - 📦 Small Arduino DMX controller project files
ZIP from the project’s author. The original sketch and wiring images.
Quick Solutions to Questions related to Small Arduino DMX controller:
- What Arduino boards can be used with this DMX controller?
Arduino Mega, Arduino UNO, and similar devices can be utilized with minor modifications; Arduino Nano can be used but is limited to one USART. - How many analog DMX channels does the project provide?
The setup includes six analog channels (potentiometers) mapped to DMX channels 1 to 6. - How are pushbuttons read and used in the project?
Pushbuttons are connected to digital inputs using internal pullup resistors; pressed reads as 0 and not pressed as 1, controlling binary DMX channels. - How are analog readings converted for DMX values?
Analog 10-bit values (0–1023) are scaled down to 8-bit (0–255) by shifting right two bits in the scale function. - Which DMX library is required?
You need to download and install the Arduino four universes DMX 512 library (lib_dmx). - What compilation error is mentioned and how to check for it?
The error ArduinoDmxN was not defined in this scope can occur; verify the correct board type is selected in the Arduino IDE under Tools > Board. - What limitation does Arduino Nano impose?
Using Arduino Nano restricts use to a single USART, referenced as ArduinoDmx0 or USART0. - Are there any programming steps required for the DMX shield?
It is required to uninstall the DMX shield before programming and reinstall it after programming.
