Hey guys,
Im trying to make a police siren but i ran into some problems:
This siren has the blue and red flashing leds and a active buzzer.
But im trying to separate the code by adding a second void loop, and while uploading i get this error message: redefinition of 'void loop()'. Is there a way that i can separate my code because else it does not work. This is my code:
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int i=0;
void setup() {
// put your setup code here, to run once:
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(6, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
delay(250);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
delay(250);
}
void loop() {
for(i=700;i<800;i++){
tone(9,i);
delay(250);
}
for(i=800;i<700;i--){
tone(9,i);
delay(250);
}
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.