need LED and TONE to start togheter

Hi there

I want my 4 LED to BLINK the when power ON, also want the tone to sweep at the same time.
As my code is now, the tone is first, then the LED goes ON.

How can I get the LED and TONE to start toghether ? :slight_smile:

Thank you

void setup() {

#include <math.h>
// put your setup code here, to run once:
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(11,OUTPUT);

int i;

for (i = 600; i <= 5000; i++) {
tone(8, i);
delay(1);}

noTone(8);

digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6, LOW);
delay(1000);
digitalWrite(2,LOW);
delay(1000);
digitalWrite(3,LOW);
delay(1000);
digitalWrite(4,LOW);
delay(1000) ;
digitalWrite(5,LOW);
delay(1000) ;
digitalWrite(6,HIGH);
delay(100) ;
}

void loop()
{
#include <math.h>

float val = (exp(sin(millis()/2000.0*PI)) - 0.36787944)*108.0;
analogWrite(11, val);

}

Get rid of the calls to delay. Look at the blink without delay example in the IDE for clues, or Robin2's most popular thread.

Please remember to use code tags when posting code,

I have read the Blink without Delay.

But I could not find out how to use that in my setup. I dont want 1 led to blink, I want many led to do an opperation (blinking, fading, flashing) and want it all to happen at the same time, not one by one.

The only way I find to do this right now is to use 2 Arduino cards. One that make sound and one that make the LED blinks .

You could do this in the setup() function, but it can easily be done in the loop() function. If you can see the difference in turning on two LEDs 0.1 milliseconds apart, then you may have a problem. None of the people that I know can do better than 100 times this.

As you were told by AWOL, lose the calls to delay(...) and study the Blink Without Delay (BWOD) example.