So I am very new to this, but this is what I have done. I got some LEDs blinking the way I want, but then I add a loop for a siren and it slows everything down. Here is the code:
/*
*/
// the setup function runs once when you press reset or power the board
int i=0;
void setup() {
pinMode(13, OUTPUT); // Blue
pinMode(12, OUTPUT); // Blue
pinMode(11, OUTPUT); // Red
pinMode(10, OUTPUT); // Red
pinMode(9, OUTPUT); //White
pinMode(8, OUTPUT); //Buzzer
pinMode(7, OUTPUT); //White
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
delay(150);
digitalWrite(13, LOW);
digitalWrite(12, LOW);
delay(150);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
delay(100);
digitalWrite(7, HIGH);
digitalWrite(9, HIGH);
delay(5);
digitalWrite(7, LOW);
digitalWrite(9, LOW);
delay(5);
for(i=700;i<800;i++){
tone(8,i);
delay(15);
}
for(i=800;i>700;i--){
tone(8,i);
delay(15);
}
}
I have also tried to change it to using more functions (I think thats what they are called) but doesn't work at all:
/*
*/
// the setup function runs once when you press reset or power the board
int i=0;
void setup() {
pinMode(13, OUTPUT); // Blue
pinMode(12, OUTPUT); // Blue
pinMode(11, OUTPUT); // Red
pinMode(10, OUTPUT); // Red
pinMode(9, OUTPUT); //White
pinMode(8, OUTPUT); //Buzzer
pinMode(7, OUTPUT); //White
}
void loop(){
void lightbar();
void buzz();
}
// the loop function runs over and over again forever
void lightbar() {
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
delay(150);
digitalWrite(13, LOW);
digitalWrite(12, LOW);
delay(150);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
delay(100);
digitalWrite(7, HIGH);
digitalWrite(9, HIGH);
delay(5);
digitalWrite(7, LOW);
digitalWrite(9, LOW);
delay(5);
}
void buzz(){
for(i=700;i<800;i++){
tone(8,i);
delay(15);
}
for(i=800;i>700;i--){
tone(8,i);
delay(15);
}
}
I would like to have the lights blink and the buzzer to go off at the same time. Seems that the lights blink, then the siren goes off, then the lights blink etc. How can I get them to work at the same time,
any help would greatly be appreciated,