hi
im really stuck im trying to make a mute button to so when alarm sounds i can mute it with a button, i just cant make it work, any help greatly appreciated thanks
// input and alatm circuit, if any inputs are on for more > 30 seconds alarm sounds, mute button to turn off alarm.
int inputA = 2; // input a
int inputB = 3; // input b
int mute = 4; // mute low input
int led = 5; // LED on pin 3
int alarm = 6; // alarm sounds
int abgood = 7; // healthy a and b inputs made.
int abfail = 8; // FAIL a or b failed.
int inputaval; // val for reading input a
int inputbval; // val for reading input b
boolean running = false;
void setup()
{
pinMode(inputA, INPUT); //input
digitalWrite(inputB, HIGH); //turn on pullup r
pinMode(inputB, INPUT); //input
digitalWrite(inputB, HIGH); //turn on pullup r
pinMode(mute, INPUT); //mute push switch input
digitalWrite(mute, HIGH); //turn on pull up r
pinMode(led, OUTPUT); //led to show
pinMode(alarm, OUTPUT); //alarm circuit.
pinMode(abgood, OUTPUT); //lights up green led for healthy status.
pinMode(abfail, OUTPUT); //lights up red led for a fail.
}
void loop(){
inputaval = digitalRead(inputA); // read input value and store it in val1
inputbval = digitalRead(inputB); // read input value and store it in val2
if ((inputaval == LOW) && (inputbval == LOW))
{
delay(1000);
digitalWrite(abgood, HIGH); // a and B inputs are healthy.
digitalWrite(alarm, LOW); // no alarm
digitalWrite(abfail, LOW); // no fail led lit
} else{
delay (1000);
digitalWrite(alarm, HIGH); // Alarm sounds ****want to MUTE/toggle this output****
digitalWrite(abfail, HIGH); // fail led lit.
if (digitalRead(mute) == LOW) // switch is pressed - pullup keeps pin high normally
delay(100); // delay to debounce switch
running = !running; // toggle running variable
digitalWrite(alarm, running); // indicate via LED
}}