alarm acknowledge-programming issue

Hi all........

Am a beginner.I just started programming using Arduino uno - a small alarm system

i have 2 alarm input.2 output connected to LED.

if any of the alarm i/p triggered the o/p LED of that channel will lit,A common alarm will generate

( a buzzer connected with that output) ,and my problem is i need to mute the buzzer with a alarm ack

input,when the next alarm triggered the buzzer should start again. Alarm code is working fine only get

stcuk with the ack.

i checked the similar posts before but cant find any answer satisfactory.

:frowning: plz help me

You have some code you didn't post.

The code does something that you don't want, or doesn't do something you do want. It isn't clear which.

You have some hardware connected to the Arduino. You did not provide sufficient details about any of the hardware. Nor did you post a schematic.

There really isn't much help we can provide, with so little information.

Hi paul ,

Here is the code which i written.But am still confused about the ack function.

/*
alarm with Acknowledge

If the input turns 0 to 1 o/p led blinks with the common buzzer o/p.if ack i/p (push button) pressed the buzzer will mute.
but if the second alarm triggered buzzer will get activated again.
*/
const int ack= 6;
const int buzzer = 9;
const int input1=2;
const int input2=3;
const int led1=7;
const int led2=8;

int S1;
int S2;

void setup() {

pinMode (input1,INPUT);
pinMode (input2,INPUT);
pinMode (ack,INPUT);
pinMode (led1,OUTPUT);
pinMode (led2,OUTPUT);
pinMode (buzzer,OUTPUT);

}

void loop() {
S1=digitalRead(input1);
S2=digitalRead(input2);

if (S1==HIGH)
{
digitalWrite (led1,HIGH);
delay(500);
digitalWrite (led1,LOW);
delay(500);
digitalWrite (led1,HIGH);
digitalWrite (buzzer,HIGH);
}
else
{
digitalWrite (led1,LOW);
}
if
(S2==HIGH )
{
digitalWrite (led2,HIGH);
delay(500);
digitalWrite (led2,LOW);
delay(500);
digitalWrite (led2,HIGH);
digitalWrite (buzzer,HIGH);
}
else
{
digitalWrite (led2,LOW);

}
}

Looks like you need to act when the alarm becomes triggered rather than when it is triggered. Look at the StateChangeDetection example in the IDE.

Hiiii.......

i tried with that but for the second alarm will buzzer will not get active as the ack input stays high for

ever.when i used state change detection i compared the switch position also with S1==HIGH;

it was like

if

(S1==HIGH && Ack==LOW)

digitalWrite (buzzer,LOW);

}

You snippet of code does not provide enough information as to how you tried to use state change detection so please post the full program or a shorter but complete example of the problem.

The principle is simple. Read the input and if it is different than last time it was read and is now in the state that indicates that it has become activated then do something. Each time you read the input save it before reading it again so that you can detect the next time it changes.

Hello,

Could you please give the ack code for me am stuck with that doing lot of stupid things.

see the code

/*
 alarm with reset. if the input turns 0 to 1 o/p led blinks with the common buzzer o/p.if reset i/p (push button) pressed the buzzer will mute.
 but if the second alarm triggered buzzer will get activated again. 
 */
const int reset= 6;   
const int buzzer = 9;      
const int input1=2;
const int input2=3;
const int led1=7;
const int led2=8;
int S1;
int S2;
int buttonState = 0;        
int lastButtonState = 0;     
int ack;

void setup() {
  

 pinMode (input1,INPUT);
 pinMode (input2,INPUT);
 pinMode (reset,INPUT);
 pinMode (led1,OUTPUT);
 pinMode (led2,OUTPUT);
 pinMode (buzzer,OUTPUT);


}


void loop() {
  
  
   buttonState = digitalRead(reset);

  
  if (buttonState != lastButtonState) {

digitalWrite (ack,HIGH);
 lastButtonState = buttonState;
  }
  if 
 (lastButtonState = buttonState)
 digitalWrite (ack,LOW);
  S1=digitalRead(input1);
  S2=digitalRead(input2);

   if (S1==HIGH )
    
  {
  digitalWrite (led1,HIGH);
  delay(500);
  digitalWrite (led1,LOW);
  delay(500);
  digitalWrite (led1,HIGH);

  }
 else
  {
  digitalWrite (led1,LOW);
}
  if 
  (S2==HIGH ) 
  {
   digitalWrite (led2,HIGH);
   delay(500);
   digitalWrite (led2,LOW);
   delay(500);
   digitalWrite (led2,HIGH);
 
  }
  else
  {
  digitalWrite (led2,LOW);
  
  }
 if 
 
 (S1==HIGH || S2==HIGH){
  if (ack=LOW){
  digitalWrite(buzzer,HIGH);
}
}}

:frowning: :frowning: :frowning: :frowning:

nideeshtvme:
Hello,
Could you please give the ack code for me am stuck with that doing lot of stupid things.

The best way to stop doing stupid things is to learn. The way to learn is by doing.

Post one of your attempts and any error messages. If there are no errors then tell us what happens when you run the program and what should happen.

Dear ...

Am not getting any errors...But i trying to write the ack code from the last one week but no way to get it.

from the beginning itself am using the state change detection. The condition should be like this ...

a common buzzer o/p activates with the o/p led if a input triggered.This we can do but even if we write the

code for ack ,when the next time the arduino scan the code buzzer will be activate again.If we maintained the

ack input high always for the next alarm buzzer will not activate.Simply once we got a an alarm and the

buzzer get activated after ack it should not scan the alarm code again we need to write some code like that

something like a flip-flop action.

when the next time the arduino scan the code buzzer will be activate again.

No it won't. If the code is written properly the buzzer will not be activated until the input changes to the activated state again. The code needs to look for the state change not just the fact that the input is in a particular state.