Conceptinetics DMX library, detecting DMX Signal loss.

Hey guys, I’m not sure if this is the correct place to post this, I did my best.

Anyhow I’m attempting to use the conceptinetics DMX library to build an rgb led strip.

I’m working with an arduino uno and one of the many popular dmx shields. currently I just have two leds attached, one reacts to input from the 1st dmx channel, the second one lights when dmx is received and off when dmx times out.

I have followed the examples within the library and as far as receiving the DMX signal and lighting the leds I have no problem at all. the problem is when I try the example sketch DMX_Slave_Signal_Timeout.

I modified the code slightly to light the 2nd led when signal is received and turn it off after signal timout, this part works as expected, the first led though is another story, if I send a dmx value above 127 on dmx channel 1 it does light (as expected) but I flickers off randomly, sometimes it will stay lit for several seconds without a flicker but then it will start to flicker off other times multiple times per second.

any help would be very much appreciated as I’m stumped as to what could be going on.

Here is my slightly modified version of the example I’m using:

#include <Conceptinetics.h>


#define DMX_SLAVE_CHANNELS   10 



// Configure a DMX slave controller
DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS );

const int ledPin = 3;
const int led2Pin = 5;

unsigned long       lastFrameReceivedTime;
const unsigned long dmxTimeoutMillis = 10000UL;


// the setup routine runs once when you press reset:
void setup() {             
  
  // Enable DMX slave interface and start recording
  // DMX data
  dmx_slave.enable ();  
  
  // Set start address to 1, this is also the default setting
  // You can change this address at any time during the program
  dmx_slave.setStartAddress (1);
  
  //
  // Register on frame complete event to determine signal timeout
  //
  dmx_slave.onReceiveComplete ( OnFrameReceiveComplete );
  
  // Set led pin as output pin
  pinMode ( ledPin, OUTPUT );
  pinMode ( led2Pin, OUTPUT );
}

// the loop routine runs over and over again forever:
void loop() 
{
   // Get current time
   unsigned long now = millis();
 
   // If we didn't receive a DMX frame within the timeout period 
   // clear all dmx channels
   if ( now - lastFrameReceivedTime > dmxTimeoutMillis )digitalWrite(led2Pin,LOW),dmx_slave.getBuffer().clear();
   else digitalWrite(led2Pin,HIGH);
 
  //
  // EXAMPLE DESCRIPTION
  //
  // If the first channel comes above 50% the led will switch on
  // and below 50% the led will be turned off
  
  // NOTE:
  // getChannelValue is relative to the configured startaddress
  if ( dmx_slave.getChannelValue (1) > 127 )
    digitalWrite ( ledPin, HIGH );
  else
    digitalWrite ( ledPin, LOW );
    
}

void OnFrameReceiveComplete (unsigned short channelsReceived)
{
  if ( channelsReceived == DMX_SLAVE_CHANNELS)
  {
    // All slave channels have been received
  }
  else
  {
    // We have received a frame but not all channels we where 
    // waiting for, master might have transmitted less
    // channels
  }

  // Update receive time to determine signal timeout
  lastFrameReceivedTime = millis ();
}