Show Posts
Pages: 1 ... 16 17 [18] 19 20 21
256  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
  }}


257  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
258  Using Arduino / Programming Questions / Re: internal pull up r's on: April 20, 2012, 07:46:55 am
ok thank you awal
259  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
260  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
261  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
262  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
263  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
264  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
265  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
266  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
267  Using Arduino / Programming Questions / Re: problem with my if statment on: April 19, 2012, 10:54:46 am
How have you determined that esval is your problem?

well im sot sure, im sure its not even reading esval, because the statment works but without the (esval == LOW)
268  Using Arduino / Programming Questions / Re: problem with my if statment on: April 19, 2012, 10:42:05 am
yes im using external pull ups
269  Using Arduino / Programming Questions / problem with my if statment on: April 19, 2012, 10:04:25 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 supfanled = 4;            // supply fan led
int extfanled = 5;            // ext fan led.
int esled = 8;                // emergency stop switch led                                       
int gason = 3;               // green led lights if fan1 and fan2 are low connected to pin 9. healthey fan1 and fan2
int fanfault = 6;            // red led lights if fan 1 or fan2 are high connected to pin 8.  (sounds an alarm)
int relay = 12;              // gas relay
int buz = 10;                // buzzer sounds if fault
int muteoutput = 2;          // mute buzzer (removes the low in the buz circuit to mute)
int muteswitch = A7;         // mut switch low input INPUT
int es = A6;                 // emergency stop switch input.   1111                           
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


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


void setup(){
  pinMode(supfanled, OUTPUT);           // supply fan led o/p
  pinMode(extfanled, OUTPUT);           // extfan led o/p
  pinMode(gason, OUTPUT);               // Greenlled as op.
  pinMode(fanfault, OUTPUT);            // redled as op.
  pinMode(fan1, INPUT);                 // Set the switch pin as ip.
  pinMode(fan2, INPUT);                 // Set the switch pin as ip.
  pinMode(relay, OUTPUT);               // Set the switch pin as op.
  pinMode(buz, OUTPUT);                 // Set the switch pin as op.
  pinMode(muteoutput, OUTPUT);          // Set the switch pin as 1p.
  pinMode(es, INPUT);                   // Set the switch pin as 1p. *****
  pinMode(esled, OUTPUT);               // Set the switch pin as 1p 
  pinMode(muteswitch, INPUT);           // set the switch pin as ip
  digitalWrite(muteswitch, 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)) *****NOT READING A LOW ON ES PIN *******
 
  {         
    delay (1000);                             // check if both inputs show fan OK (Switch is pressed)
    digitalWrite(gason, 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(gason, LOW);                 // turn green OFF 
    digitalWrite(fanfault, HIGH);             // red led on
    digitalWrite(buz, HIGH);                  //                             
    digitalWrite(relay, LOW);                 // gas valve off
  }
  {
  if (digitalRead(muteswitch) == LOW)         // switch is pressed - pullup keeps pin high normally
    {delay(100);                              // delay to debounce switch
    running = !running;                       // toggle running variable
   digitalWrite(muteoutput, running);         // indicate via LED
    }
   digitalWrite(supfanled, fan1val);          //fan1 status led
   digitalWrite(extfanled, fan2val);          //fan2 status led
   digitalWrite(esled, esval);                //estop status
                                       
  }}



hi ive got a problem with my if statement i just cant see whats wrong with it,  its not reading esval in the last part, it has a low to that pin but its just not working, any help greatly appreciated
270  Using Arduino / Programming Questions / Re: using analog pins as digital on: April 10, 2012, 09:59:33 am
thank you
Pages: 1 ... 16 17 [18] 19 20 21