3ch random dmx chase/fade

hi im working on a 3ch random dmx chase. for every channel i want to control the min/max brightness and the randomness (min/max) of the fade speed on every channel indipendently. I used a led fade code for 1ch and rewrote that for use with the dmxSimple library. my code works great with one channel only but as soon as i start trying to write it for two or three channels it dosent work. I want to make a really slow fades between two to five minutes.

can someone please help me?

here is the code for the one channel random dmx fade.

#include <DmxSimple.h>



float val;


void setup()  {
  DmxSimple.usePin(3);
   randomSeed(analogRead(0));
     Serial.begin(9600);
}

void loop()  {
{
  val = random(10,255);
  val2 = random(10.255);
  val3 = random(470.1176);
  
  
  }
  delay(750);
  for(int fadeValue = 10 ; fadeValue <= 255; fadeValue +=1) {
  DmxSimple.write(2, fadeValue);
    Serial.print(fadeValue); // this is to monitor the fade
  delay(val);

  }
  delay(750);
  for(int fadeValue = 255 ; fadeValue >= 10; fadeValue -=1) {
  DmxSimple.write(2, fadeValue);
    Serial.print(fadeValue);
  delay(val);
}

}

for every channel i want to control the min/max brightness and the randomness (min/max) of the fade speed on every channel indipendently.

When would you choose a new set of fade parameters for a channel?

To work with more than one channel, you need to get rid of the delay calls. Look at the Blink Without Delay example to see how to avoid the use of delay.

Then draw a flow chart, to define what happens on each pass through loop(). A flow chart has a start bubble at the top, and an end bubble at the bottom. The start and end bubbles correspond to the start and end of loop. Decide what needs to be done for each channel on each pass through loop. Some actions will depend on time. You need to keep track of when events occurred, and when the next event needs to occur (relative to the last event, not an absolute time).

thanks for the tip

i have now tried to write some new code.
but it seems that the output dmx values writes at the same time. as you can see the the loopTime is different between the channels.

is there a structural problem?

#include <DmxSimple.h>

/*
 Fade
 
 
 This example based on the Arduino Example Fade sketch
 but modified to use timing instead of the delay() function
 
 */
int brightness1 = 0;    // how bright the channel is
int fadeAmount1 = 1;    // how many points to fade the channel by
unsigned long currentTime1;
unsigned long loopTime1;

int brightness2 = 0;    // how bright the channel is
int fadeAmount2 = 1;    // how many points to fade the channel by
unsigned long currentTime2;
unsigned long loopTime2;

int brightness3 = 0;    // how bright the channel is
int fadeAmount3 = 1;    // how many points to fade the channeö by
unsigned long currentTime3;
unsigned long loopTime3;
void setup()  { 

  Serial.begin(9600); //serial for debugging
    DmxSimple.usePin(3);
  currentTime1 = millis();
  loopTime1 = currentTime1; 
  
    currentTime2 = millis();
  loopTime2 = currentTime2; 
  
    currentTime3 = millis();
  loopTime3 = currentTime3; 
} 

void loop()  { 
  currentTime1 = millis();
  if(currentTime1 >= (loopTime1 +1000))
  
    currentTime2 = millis();
  if(currentTime2 >= (loopTime2 +500))
  
    currentTime3 = millis();
  if(currentTime3 >= (loopTime3 +2000))
  
  {
    {
      {  
  
    DmxSimple.write(2, brightness1);    //sends channel and the brightness
Serial.print("Brightnes1:");
Serial.println(brightness1);
    // change the brightness for next time through the loop:
    brightness1 = brightness1 + fadeAmount1;

    // reverse the direction of the fading at the ends of the fade: 
    if (brightness1 == 0 || brightness1 == 255) {
      fadeAmount1 = -fadeAmount1 ; 
    }     
    loopTime1 = currentTime1;  // Updates loopTime
  }
  
  // Other processing can be done here
    DmxSimple.write(3, brightness2);    //sends channel and the brightness
Serial.print("Brightnes2:");
Serial.println(brightness2);
    // change the brightness for next time through the loop:
    brightness2 = brightness2 + fadeAmount2;

    // reverse the direction of the fading at the ends of the fade: 
    if (brightness2 == 0 || brightness2 == 255) {
      fadeAmount2 = -fadeAmount2 ; 
    }     
    loopTime2 = currentTime2;  // Updates loopTime
}

    DmxSimple.write(4, brightness3);    //sends channel and the brightness
Serial.print("Brightnes3:");
Serial.println(brightness3);
    // change the brightness for next time through the loop:
    brightness3 = brightness3 + fadeAmount3;

    // reverse the direction of the fading at the ends of the fade: 
    if (brightness3 == 0 || brightness3 == 255) {
      fadeAmount3 = -fadeAmount3 ; 
    }     
    loopTime3 = currentTime3;  // Updates loopTime

}
}

im not there with the randomness yet but i guess i just have to change the loopTime+ value to a random one.

You have quite different behavior when the first three if tests are true. The action for one channel should be completely independent of the action for the other channels, I would think.

  if(currentTime3 >= (loopTime3 +2000))
  
  {
    {
      {

Really, now one { is enough.