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

Small Arduino DMX controllerKnown 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:

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

Sample code to test the operation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//*********************************************************************************************************
#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()
{
Small Arduino DMX controller Schematic  // 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()
//*************************************************************************************************************

 

For more detail: Small Arduino DMX controller


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

Scroll to Top