Show Posts
Pages: 1 ... 16 17 [18] 19 20 ... 22
256  Using Arduino / Programming Questions / help adding a mute button and delay on: April 24, 2012, 05:08:57 am
Code:
*
 *  2 switches monitoring two fans, healthly if both fan1 and fan2 switches are low output switches a relay, if any input high an alarm sounds no output to relay.
 */
                              //int muteoutput = 2;          // mute buzzer (removes the low in the buz circuit to mute) XXXXX


int Buz = 10;                // buzzer sounds if fault
int Mute = A2;               // mut switch input   

int Service = 9;             // service switch                           
int Supfanled = 4;           // supply fan led
int Extfanled = 5;           // ext fan led.
int Esled = 8;               // emergency stop switch led                                       
int Relay = 3;               // green led lights if fan1 and fan2 are low connected to pin 9. healthey fan1 and fan2
int Gasled = 12;             // led to indicate gas is on.
int Fanfault = 6;            // red led lights if fan 1 or fan2 are high connected to pin 8.  (sounds an alarm)
int Es = A3;                 // emergency stop switch input.                               
int Fan2 = A5;               // fan switch is connected to pin 3 
int Fan1 = A4;               // fan switch is connected to pin 2 
int Fan1val;                 // var for reading the pin status
int Fan2val;                 // var for reading the pin status
int Esval;                   // val for reading emergency stop status
int Srviceval;               // val for service status.

boolean running = false;     // *****


void setup(){                                                 
  Serial.begin(9600);
  pinMode(Service, INPUT);              // service switch on just gas operates nothing else
  digitalWrite(Service, HIGH);          //turn on pulup r
  pinMode(Supfanled, OUTPUT);           // supply fan led o/p
  pinMode(Extfanled, OUTPUT);           // extfan led o/p
  pinMode(Gasled, OUTPUT);               // Greenlled as op.
  pinMode(Fanfault, OUTPUT);            // redled as op.
  pinMode(Fan1, INPUT);                // Set the switch pin as ip.
  digitalWrite(Fan1, HIGH);             // turn on internal r
  pinMode(Fan2, INPUT);                 // Set the switch pin as ip.
  digitalWrite(Fan2, HIGH);             // turn on internal r
  pinMode(Relay, OUTPUT);               // Set the switch pin as op.
  pinMode(Buz, OUTPUT);                 // Set the switch pin as op.
  pinMode(Mute, OUTPUT);                // Set the switch pin as 1p.
  pinMode(Es, INPUT);                   // Set the switch pin as 1p. *****
  digitalWrite(Es, HIGH);               // turn on pullup r
  pinMode(Esled, OUTPUT);               // Set the switch pin as 1p 
  pinMode(Mute, INPUT);                 // set the switch pin as ip
  digitalWrite(Mute, HIGH);             // turn on pullup resistor
}
 void loop(){
  Fan1val = digitalRead(Fan1);            // read input value and store it in fan1
  Fan2val = digitalRead(Fan2);            // read input value and store it in fan2
  Esval = digitalRead(Es);                // read estop value and store value
 
  if ((Fan1val == LOW) && (Fan2val == LOW) && (Esval == LOW))
 
  {         
    delay (1000);                             // check if both inputs show fan OK (Switch is pressed)
    digitalWrite(Gasled, HIGH);               // turn green led on.
    digitalWrite(Relay, HIGH);                // turn on gas relay.
    digitalWrite(Buz,LOW);                    // buzzer off, no error
    digitalWrite(Fanfault,LOW);               // red led off no fault
                                           
  } else{   
    delay (1000);                               
    digitalWrite(Gasled, LOW);                // turn green OFF     
    digitalWrite(Relay, LOW);                 // turn off relay     **** Turn off Relay if fault has been greater than 30 seconds*****
    digitalWrite(Fanfault, HIGH);             // red led on
    digitalWrite(Buz, HIGH);                  // Alarm on            ****want to toggle this on/off only when fault, with the mute button *******               
   
    digitalWrite(Supfanled, Fan1val);          //fan1 status led
    digitalWrite(Extfanled, Fan2val);          //fan2 status led
    digitalWrite(Esled, Esval);                //estop status
   }}
 


hi,
im really struggling with my program and im stuck, all i need to finish my project is to add a mute to my alarm,  and a 30 sec delay to my relay.

finding it really difficuly to understand mills() to add a delay and boolean to make a mute button, hope someone could help me maby if i see the code it will help understand how these work and help me go faward
thank you
257  Using Arduino / Programming Questions / Re: help with boolean on: April 22, 2012, 10:06:55 am
Code:


             //    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 button, 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 a input
  digitalWrite(InputA, HIGH);     //turn on pullup r
  pinMode(InputB, INPUT);         //input b 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 fan1
  InputBval = digitalRead(InputB);            // read input value and store it in fan2
  
  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
 





yes paul i see what you mean, looks more logical will take on board your advice thank you
258  Using Arduino / Programming Questions / Re: help with boolean on: April 22, 2012, 09:56:07 am
hi bill,
sorry i wasnt very clear im trying to make it mute until the error goes away, and to allow subsequent alarms to be sounded if the conditions occur
thank you
259  Using Arduino / Programming Questions / Re: help with boolean on: April 22, 2012, 09:06:50 am
ok points taken paul
will re post using your advice thanks
260  Using Arduino / Programming Questions / help with boolean on: April 22, 2012, 08:17:29 am
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
Code:
          //    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
  }}


261  Using Arduino / Programming Questions / Re: how to get a delay in an if statment on: April 20, 2012, 11:50:24 am
thanks for the help, i will read up in boolean and mills
262  Using Arduino / Programming Questions / Re: internal pull up r's on: April 20, 2012, 07:46:55 am
ok thank you awal
263  Using Arduino / Programming Questions / Re: internal pull up r's on: April 20, 2012, 07:24:16 am

pinMode(fan1, INPUT_PULLUP);


tyred that but got, was not declared at this scope, im using arduino 1.0
264  Using Arduino / Programming Questions / how to get a delay in an if statment on: April 20, 2012, 07:02:32 am
hi,

i would like to put a time statment/delay in an if statment, have searched but cant find any info this is what id like to do.
 
if ((inputa ==low) && (inputb ==low)) they both have to be low > 20 seconds.

then do this... 

maby someone could point me in the right direction thank you
265  Using Arduino / Programming Questions / Re: internal pull up r's on: April 19, 2012, 02:43:44 pm
thank you, ive got it amazing, internal r's
266  Using Arduino / Programming Questions / internal pull up r's on: April 19, 2012, 02:04:02 pm
Code:
void setup(){
  Serial.begin(9600);
  pinMode(supfanled, OUTPUT);           // supply fan led o/p
  digitalWrite(supfanled, HIGH);        // turn on pullup resistors

hi
just stumbled upon internal pull up r's, is this the correct place (setup) to define the internal pull up r's?
thank you
267  Using Arduino / Programming Questions / Re: problem with my if statment on: April 19, 2012, 11:37:30 am
tryed another pin and its ok, must be a faulty pin/board

thanks very much for the help, really appreciate it
268  Using Arduino / Programming Questions / Re: problem with my if statment on: April 19, 2012, 11:31:28 am
yes ove got 0v, then plus 5, then ov, using a meter, going to try another pin maby its a faulty pin, but its a new board
269  Using Arduino / Programming Questions / Re: problem with my if statment on: April 19, 2012, 11:20:13 am
im getting a 0 low all the time monitoring it through serial monitor even though im using a pull up resistor, ive checked the circuit many times
270  Using Arduino / Programming Questions / Re: problem with my if statment on: April 19, 2012, 11:03:50 am
yes ive measured it several times 3 lows all the time, ill add a Serial.print(esval) and see
Pages: 1 ... 16 17 [18] 19 20 ... 22