Tuturial: RGB led lighting via DMX

In this tutorial we will see how we can change the colors of a strip of LEDs using the DMX protocol.

 

¿What do I need?

 

1. One RGB led strip

This is a strip that has a lot of sectors of tri-color LEDs (red, green and blue).

 

ledStrip leds

 

 

2. One winkhel WK0100 or one winkhel WK0400

It is better the WK0100 because you can send the program directly from the Arduino using a USB cable.

wk0100

3. One RGB led lighting controller DMX

 

 

dmxController

¿How do I connect the devices?

The connection of the devices is simple, you have to connect the RS485 port (A and B) of the WK0100 with DMX controller and this one with led strip as shown in the following schematic:

 

 

dmx

 

 

Software and addressing

1. Addressing of DMX controllers

Each DMX controller connected to the bus takes an address that is configured on switches located on the housing. In this case, as we only have one controller and one led strip, the address must be 1, so we put ON the switch number 1 and the rest OFF. If we have more than one DMX controller in the bus, you have to know that the DMX protocol is addressed by channel. A channel is each of the colors that we control. Thus, each DMX controller that I want to connect to the bus occupies three channels, so the second DMX controller has the addres 4, the next the address 7 and so on. The address is coded in binary in the switches of the housing of each DMX controller.

 

2. Programa

Let's do the program in the Arduino IDE, you can download from their official website: http://arduino.cc.

Now you need to add the DMXSerial library, can be found on the web http://www.mathertel.de/Arduino/DMXSerial.aspx, to download click here. In addition to the .cpp and .h own of the library, also contains some examples but here we will program a code easier.

The code is:


#include <DMXSerial.h>


void setup() {

DMXSerial.init(DMXController);

}


void loop() {

DMXSerial.write(1, 255);

DMXSerial.write(2, 0);

DMXSerial.write(3, 0);


delay(5000);

DMXSerial.write(1, 255);

DMXSerial.write(2, 255);

DMXSerial.write(3, 0);

delay(5000);

DMXSerial.write(1, 0);

DMXSerial.write(2, 0);

DMXSerial.write(3, 150);

 

delay(5000);

}

 

 

  • In the setup initializes the library, we are indicating that we will use it to send commands DMX, this is essential for the program to work.
  • There is only one function: write(channel, color)
  • The first parameter is the channel number. If we want to set the red level of the DMX controller number 1, we have to write a 1. To configure level of green of the same DMX controller we have to put a 2 and for configuring the level of green, a 3.
  • The second parameter is the level of color you want to set, from 0 to 255. The lower the level, the less intense, therefore colors are lighter. The higher, the stronger, so darker colors. Thus, the black color is R = 0 G = 0 B = 0 (LEDs off) and white is R = 255 G = 255 B = 255.
  • In the example, we configure first red color (R = 255, G = 0, B = 0), then yellow collor (R = 255, G = 255, B = 0) and finally dark blue color (R = 0, G = 0, B = 150).

 

You can modify the code so that the LEDs show the colors you want:

rgb colors