Home Arduino projects Small Arduino DMX controller
formats

Small Arduino DMX controller

In this post we show you how to make a small and useful Arduino DMX512 controller, which can use by example to handle a smoke machine with DMX, or as test equipment, etc…

We can use Arduino Mega, Arduino UNO, and other with small changes.
Only a handful of inexpensive components are used.

In the configuration shown we have 6 channels with variable values, provided by 6 potentiometers connected to the Arduino analog inputs, 10-bit values are reduced to 8 bits (0-255 who are used by DMX), and 12 channels with on-off values with 12 push buttons connected to the digital inputs of the arduino, digital inputs are using the arduino internal pullup resistors, so if the button is pressed the input value is 0, and if it is free the input value is 1.

You need dowload and install our Arduino four universes DMX 512 library

Download project and source code Small Arduino DMX controller

Known issues:
When we compile get the error: ‘ArduinoDmxN’ was not Declared In This scope:
Check if you have configured the correct type of board in the Arduino IDE, menu tools > board
(with Arduino nano can only use one USART = ArduinoDmx0 = USART0)
Errors while programing Arduino:
Will be necessary to remove the DMX shield, and put it back once programmed.

In the following images have the wiring:

Schematic Small Arduino DMX controller

Schematic Small Arduino DMX controller

Small Arduino DMX controller

Small Arduino DMX controller

Images and drawings made with Fritzing: www.fritzing.org

 

Sample code to test the operation:

//*********************************************************************************************************
#include <lib_dmx.h>  // libreria DMX 4 universos   // four universes DMX library  - www.deskontrol.net/blog

//*********************************************************************************************************
//                        New DMX modes *** EXPERIMENTAL ***
//*********************************************************************************************************
#define    DMX512     (0)    // (250 kbaud - 2 to 512 channels) Standard USITT DMX-512
#define    DMX1024    (1)    // (500 kbaud - 2 to 1024 channels) Completely non standard - TESTED ok
#define    DMX2048    (2)    // (1000 kbaud - 2 to 2048 channels) called by manufacturers DMX1000K, DMX 4x or DMX 1M ???

void setup() 
{
  // configurar pines arduino del 2 al 13 como entradas con pullup, (cuando se pulsa el boton = 0 si no = 1)
  // configure arduino pins 2 to 13 as inputs with pullup, (button pressed = 0, button free = 1) 
  for (int i=2;i<=13;i++) 
  {
    pinMode(i,INPUT);            // pines como entradas       
                                 // pins as inputs
    digitalWrite(i, HIGH);       // activar resistencias pullup internas
                                 // turn on pullup internal resistors
  }

  ArduinoDmx0.set_tx_address(1);      // poner aqui la direccion de inicio de DMX 
                                      // put here DMX start address 

  ArduinoDmx0.set_tx_channels(100);   // poner aqui el numero de canales a transmitir 
                                      // put here the number of DMX channels to transmmit

  ArduinoDmx0.init_tx(DMX512);        // iniciar transmision universo 0, modo estandar DMX512
                                      // starts universe 0 as TX, standard mode DMX512
}  //end setup()

void loop()
{
  // seis entradas con potenciometros que envian valores DMX entre 0 y 255 a los canales 1 al 6
  // six analog inputs with potentiometers, sending values from 0 to 255, to dmx output channels 1 to 6

  ArduinoDmx0.TxBuffer[0] = scale(analogRead(0)); // copiar valor de la entrada analogica 0 al canal DMX 1
                                                  // copy value from analog input 0 to DMX channel 1
  ArduinoDmx0.TxBuffer[1] = scale(analogRead(1)); // copiar valor de la entrada analogica 1 al canal DMX 2
                                                  // copy value from analog input 1 to DMX channel 2
  ArduinoDmx0.TxBuffer[2] = scale(analogRead(2)); // copiar valor de la entrada analogica 2 al canal DMX 3
                                                  // copy value from analog input 2 to DMX channel 3
  ArduinoDmx0.TxBuffer[3] = scale(analogRead(3)); // copiar valor de la entrada analogica 3 al canal DMX 4
                                                  // copy value from analog input 3 to DMX channel 4
  ArduinoDmx0.TxBuffer[4] = scale(analogRead(4)); // copiar valor de la entrada analogica 4 al canal DMX 5
                                                  // copy value from analog input 4 to DMX channel 5
  ArduinoDmx0.TxBuffer[5] = scale(analogRead(5)); // copiar valor de la entrada analogica 5 al canal DMX 6
                                                  // copy value from analog input 5 to DMX channel 6

  if (digitalRead(2) == LOW)       // pulsador en pin 2 apretado  // push-button on pin 2, is pressed
    ArduinoDmx0.TxBuffer[6] = 255; // enviar 255 al canal DMX 7   // send value 255 to DMX channel 7
  else
    ArduinoDmx0.TxBuffer[6] = 0;   // si no enviar 0              // push-button free, send 0

  if (digitalRead(3) == LOW)       // pulsador en pin 3 apretado
    ArduinoDmx0.TxBuffer[7] = 255; // enviar 255 al canal DMX 8
  else
    ArduinoDmx0.TxBuffer[7] = 0;   // si no enviar 0

  if (digitalRead(4) == LOW)       // pulsador en pin 4 apretado
    ArduinoDmx0.TxBuffer[8] = 255; // enviar 255 al canal DMX 9
  else
    ArduinoDmx0.TxBuffer[8] = 0;   // si no enviar 0

  // añadir aqui hasta el pin 13
  // add here the others inputs

}  //end loop()

uint8_t scale(uint16_t value) // scale values from 10 bits to 8 bits
{
  if(value > 1023) // test for 10 bits limit
    value = 1023;

  return (value >> 2); // scale
}  //end scale()

//*************************************************************************************************************

Sample code 2:

/*************************************************************************************************************
*
*   Title		    : Controlador DMX con Arduino
*   Version		    : v 0.1
*   Last updated	    : 28.08.2012
*   Target		    : Arduino mega 2560, Arduino mega 1280, Arduino UNO, Arduino nano
*   Author                  : Toni Merino - merino.toni at gmail.com
*   Web                     : www.deskontrol.net/blog
*
*
*   Ejemplo de codigo para el mini-controlador DMX con Arduino:
*   Este codigo lee los valores de 6 potenciometros conectados a 6 entradas analogicas y escribe cada valor en la salida DMX 
*   solo cuando se presiona el pulsador correspondiente. (canales de salida 1 al 6) 
*
**************************************************************************************************************/
#include <lib_dmx.h>  // libreria DMX 4 universos   // deskontrol four universes DMX library  - www.deskontrol.net/blog

//*********************************************************************************************************
//                        New DMX modes *** EXPERIMENTAL ***
//*********************************************************************************************************
#define    DMX512     (0)    // (250 kbaud - 2 to 512 channels) Standard USITT DMX-512
#define    DMX1024    (1)    // (500 kbaud - 2 to 1024 channels) Completely non standard - TESTED ok
#define    DMX2048    (2)    // (1000 kbaud - 2 to 2048 channels) called by manufacturers DMX1000K, DMX 4x or DMX 1M ???

uint8_t    buffer[6];        // buffer DMX data

void setup() 
{
  // configurar pines arduino del 2 al 13 como entradas con pullup, (cuando se pulsa el boton = 0 si no = 1)
  // configure arduino pins 2 to 13 as inputs with pullup, (button pressed = 0, button free = 1) 
  for (int i=2;i<=13;i++) 
  {
    pinMode(i,INPUT);            // pines como entradas       
                                 // pins as inputs
    digitalWrite(i, HIGH);       // activar resistencias pullup internas
                                 // turn on pullup internal resistors
  }
  
  ArduinoDmx0.set_tx_address(1);      // poner aqui la direccion de inicio de DMX 
                                      // put here DMX start address 
                                      
  ArduinoDmx0.set_tx_channels(100);   // poner aqui el numero de canales a transmitir 
                                      // put here the number of DMX channels to transmmit
                                      
  ArduinoDmx0.init_tx(DMX512);        // iniciar transmision universo 0, modo estandar DMX512
                                      // starts universe 0 as TX, standard mode DMX512
}  //end setup()

void loop()
{
  // seis entradas con potenciometros que envian valores DMX entre 0 y 255 a los canales 1 al 6, cuando se presiona el pulsador
  // six analog inputs with potentiometers, sending values from 0 to 255, to dmx output channels 1 to 6, when switch is pressed
  
  buffer[0] = scale(analogRead(0)); // copiar valor de la entrada analogica 0 al canal DMX 1
                                    // copy value from analog input 0 to DMX channel 1
  buffer[1] = scale(analogRead(1)); // copiar valor de la entrada analogica 1 al canal DMX 2
                                    // copy value from analog input 1 to DMX channel 2
  buffer[2] = scale(analogRead(2)); // copiar valor de la entrada analogica 2 al canal DMX 3
                                    // copy value from analog input 2 to DMX channel 3
  buffer[3] = scale(analogRead(3)); // copiar valor de la entrada analogica 3 al canal DMX 4
                                    // copy value from analog input 3 to DMX channel 4
  buffer[4] = scale(analogRead(4)); // copiar valor de la entrada analogica 4 al canal DMX 5
                                    // copy value from analog input 4 to DMX channel 5
  buffer[5] = scale(analogRead(5)); // copiar valor de la entrada analogica 5 al canal DMX 6
                                    // copy value from analog input 5 to DMX channel 6
  
  if (digitalRead(2) == LOW)             // pulsador en pin 2 apretado                  // push-button on pin 2, is pressed
    ArduinoDmx0.TxBuffer[0] = buffer[0]; // enviar valor potenciometro al canal DMX 1   // send analog value to DMX channel 1
  else
    ArduinoDmx0.TxBuffer[0] = 0;         // si no enviar 0                              // push-button free, send 0
        
  if (digitalRead(3) == LOW)             // pulsador en pin 3 apretado                  // push-button on pin 3, is pressed
    ArduinoDmx0.TxBuffer[1] = buffer[1]; // enviar valor potenciometro al canal DMX 2   // send analog value to DMX channel 2
  else
    ArduinoDmx0.TxBuffer[1] = 0;         // si no enviar 0                              // push-button free, send 0
    
  if (digitalRead(4) == LOW)       
    ArduinoDmx0.TxBuffer[2] = buffer[2]; 
  else
    ArduinoDmx0.TxBuffer[2] = 0;   
    
  if (digitalRead(5) == LOW)       
    ArduinoDmx0.TxBuffer[3] = buffer[3]; 
  else
    ArduinoDmx0.TxBuffer[3] = 0;   
    
  if (digitalRead(6) == LOW)       
    ArduinoDmx0.TxBuffer[4] = buffer[4]; 
  else
    ArduinoDmx0.TxBuffer[4] = 0;   
    
  if (digitalRead(7) == LOW)       
    ArduinoDmx0.TxBuffer[5] = buffer[5]; 
  else
    ArduinoDmx0.TxBuffer[5] = 0;   
       
    
}  //end loop()


uint8_t scale(uint16_t value) // scale values from 10 bits to 8 bits
{
  if(value > 1023) // test for 10 bits limit
    value = 1023;
    
  return (value >> 2); // scale
}  //end scale()

//************************************************************************************************************************

We could for example use half of buttons as flash of DMX channels, and the other 6 as scene memories, for it we need store the DMX values in the eeprom and recall when pressing a memory …

No doubt there are many useful options to experience each, and adapt the software to our needs.

I hope to share your experiences.

Regards.

 

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
8 Comments  comments 

8 Responses

  1. rui

    Hi, there! I am actually trying to do what you did in this very helpful tutorial, except that i want to be able to control the brightness of a stage light with a pressure sensor instead of potentiometer and i will also require it to be wireless. Was thinking of using the Xbee for the wireless portion but i’m not so sure as i am not very good with such technology. Any tips will be greatly appreciated. Thank you!

  2. Ian

    Is there a way were you have a lcd and to rotary encoders one for the Channel and the other for the Brightness/ DMX value. It would be great for a controller for rigging lights in the theatre.

  3. Rodigo Pereira

    ‘”arduinoDmx0″ was not declared in this scope’
    Help me :(

    • Toni Merino

      Hi Rodrigo.

      - First copy DMX_Lib to your Arduino library folder (usually Arduino-XXXX/libraries)
      - ADD include in your file:

      #include <lib_dmx.h>

      - Have you selected right board type?

      regards

  4. Rodrigo Pereira

    thank you a lot! codes are working!
    I now have another problem :( when I open freestyler dmx, it did not find the interface … :( I selected ENTTEC DMX Open…
    what I should I do?

    • Toni Merino

      Hi Rodrigo.
      This is not an USB-DMX converter, this is a controller for test purposes, or a base for implement your own project.

      Regards.

  5. Soren Oht

    Hi Toni, Thanks for this interesting project,, I’m am a teacher, looking for a student project within electronics, for the education: “event technician” (four years education for setting up huge stages for concerts and theater). I would like to use arduino one and a DMX shield to test lights e.g.(http://www.martin.com/productgroup/productgroup.asp?psg=movingheads&selgroup=0). I’m thinking of being able to control the pan/tilt functions and also the light (dimming, colours, etc.)Could I use the “Small Arduino DMX controller for this? Thanks – BR Soren

    • Toni Merino

      Hi Soren.
      Yes, is possible to use this project for this purpose, but is best you use Arduino MEGA due to high number of inputs (16 analog inputs for DMX faders and lots of digital inputs for push buttons). This avoid the need of multiplexing for get more inputs. And you have extra USARTs for other uses.

      Regards.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">