LED combined fading and blinkin

Hi all,

I am trying to get 4 LEDs working at the same time for a diorama.
LED #1 and LED #2 should double blink (like a heartbeat) and a little asynchron.
LED #3 and #4 should fade in and out.

I managed to get everything single working (tried the original blink and blinkWithoutDelay sketch) and also the fading works fine.
When putting the codes together, then the fading works fine, but the LEDs #1 and #2 are not blinking like a heartbeat, but one after the other. Any ideas?

Thanks

Any ideas?

Read the "how to use this forum-please read" stickies to see how to properly post your code. We can't help with code that we can't see.

You are right, sorry. I just have tried tons of code… this is my actual one:

#define out_LED1 3              
#define out_LED2 4               
#define out_LED3 5
#define out_LED4 6
unsigned long time;

int helligkeit = 0;
int fadeschritte = 5;
void blinkWithoutDelay(int pin, int off, int on)
{
  int blinkPhase = millis() % (off + on);
  if (blinkPhase < off) digitalWrite(pin, LOW);
  else digitalWrite(pin, HIGH);
}

void setup() {
  pinMode(out_LED1, OUTPUT);
  pinMode(out_LED2, OUTPUT);
  pinMode(out_LED3, OUTPUT);
  pinMode(out_LED4, OUTPUT);
}

void loop() {

  blinkWithoutDelay(out_LED2, 1005, 100);
  blinkWithoutDelay(out_LED2, 105, 2000);
  blinkWithoutDelay(out_LED1, 1000, 150);
  // blinkWithoutDelay(out_LED2, 1550, 5600);
  //  blinkWithoutDelay(out_LED3, 1055, 7000);
  //  blinkWithoutDelay(out_LED4, 1090, 5060);

   
  analogWrite(out_LED4, helligkeit);
  helligkeit = helligkeit + fadeschritte ;
  if (helligkeit == 0 || helligkeit == 255)

    fadeschritte = -fadeschritte ;

    
  analogWrite(out_LED3, helligkeit);
  helligkeit = helligkeit + fadeschritte;
  
time = millis();

  Serial.println(time);    
  
  //prints time since program started
  delay(100); 
  if (helligkeit == 0 || helligkeit == 255)

    fadeschritte = -fadeschritte ;
}

Here a simpler code for better understanding:

  digitalWrite(4, HIGH);   
  delay(2000);                      
  digitalWrite(4, LOW);    
  delay(100);   
  digitalWrite(4, HIGH);   
  delay(100);                      
  digitalWrite(4, LOW);    
  delay(100);

Two of the LEDs should blink a little asynchron with the rhythm like above and the other two fading at the same time. Fading is working, but not the "easy" blinking.

Blinking and fading are identical. Just the times are different. You will never get it to work with delays. Look at "Using millis() for timing. A beginners guide" in the programming section of the forum.

Paul