I recently got into programing and I'm making an alarm. I cant figure out how to make a buzzer loop. I have two blinking LED's and two fading ones. Now I plan to have sound and it won't work. It only blinks once and stops. I would also like the two fading LED's to fade at different times. I can't figure that out. Here's the code. 8 is the buzzer and red and blue are the fading LED's.
int blue = 6;
int red = 9;
int brightness = 0;
int fadeAmount = 500;
void setup() {
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(8, OUTPUT);
}
void loop() {
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
delay(200);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
delay(200);
digitalWrite(8, LOW);
digitalWrite(8, HIGH);
delay(10);
analogWrite(red, brightness);
analogWrite(blue, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
millis();
}