Serial DMX to PWM decoder for analog RGB lights?

I am trying to control some rgb lights from software that has the ability to send dmx via usb. I do not want to actually use any dmx lights/cords, just the messages from the software set to control one rgb light, so three channels. I am hoping to use a nano and some mosfets to drive the rgb strip. I am able set the color from the serial monitor but must adapt my code to read the dmx messages correctly. Here is my code:

char buffer[16];   //maximum expected length

int REDPin = 3 ;   // RED pin of the LED to PWM pin 4
int GREENPin = 9;  // GREEN pin of the LED to PWM pin 5
int BLUEPin =5;
int len = 0;
void setup()
  pinMode(REDPin, OUTPUT);
  pinMode(GREENPin, OUTPUT);
  pinMode(BLUEPin, OUTPUT);
void loop()
  if (Serial.available() > 0)
    int incomingByte =;
    buffer[len++] = incomingByte;
    // check for overflow
    if (len >= 16)
      // overflow, resetting
      len = 0;
    // check for newline (end of message)
    if (incomingByte == '\n')
      int r, g, b;
      int n = sscanf(buffer, "%d %d %d", &r, &g, &b);
      if (n == 3)
        analogWrite(REDPin, r);
        analogWrite(GREENPin, g);
        analogWrite(BLUEPin, b);

        // valid message received, use values here..
        // parsing error, reject
      len = 0; // reset buffer counter

I am not sure about the formatting or reading of dmx messages ( I was hoping they would just be 3 values 0-255). I used serial port monitor to check traffic my results are below. The first image is of successful messages to the lights via serial monitor. The second is the messages from the dmx software. You can see the successes have rgb values in the chars column, while the failures seem to have some other format. The three bytes in the data column makes me thing its reading the channel amount correctly, but I am not sure how to use these values to drive the pwm pins.

I could also use some clarity on the difference between data and data(char) in this context. I'm also not entirely clear on bytes vs char and DEC vs hex vs ASCII and conversion which may be the issue here?

Thanks :o

why don't you use some of the existing solutions?
Search for: arduino dmx slave

Thanks, but it looks like it requires a shield. I was hoping to do it without a shield. I am receiving data on the com port but am unsure of how to translate the incoming values to pwm.

as DMX is based on RS485 you will need some kind of hardware to transform from RS485 to TTL. It doesn't matter if you use a "DMX shield", another RS485 modul or a single chip from Maxim, Texas Instruments.

In your opening post, you were asking about the software, and the search should bring up some libraries you can try.