I'm trying to get warning with buzzer while I get same values on 3 seconds. But first warning doesn't wait 3 seconds. Second warning is correct. Code is attached. BlinkLED1() method is same BlinkLED2. Probably, I'm missing crowning touch. Can you help me? Thanks in advance.
void initialsettings(double roll,double pitch){
if(level==0){
if(roll>=34 && timerstatus==false){
Timer1.initialize(3000000);
timerstatus=true;
Timer1.attachInterrupt(blinkLED);
} else{
Timer1.stop();
timerstatus=false;
level=0;
}
}else if(level==1){
if(roll<=-34 && timerstatus==false){
Timer1.initialize(3000000);
timerstatus=true;
Timer1.attachInterrupt(blinkLED2);
} else{
Timer1.stop();
timerstatus=false;
}
}else if(level==2){
}
}
void blinkLED(void)
{
noInterrupts();
Timer1.stop();
//Timer1.restart();
digitalWrite(buzzerpin,HIGH);
delay(7000);
digitalWrite(buzzerpin,LOW);
timerstatus=false;
interrupts();
if(level==0){
level=1;
Serial.println("level 1");
}
Serial.println("Sag ");
//Serial.print("\n");
}