Show Posts
Pages: 1 ... 17 18 [19] 20 21 22
271  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)
272  Using Arduino / Programming Questions / Re: problem with my if statment on: April 19, 2012, 10:42:05 am
yes im using external pull ups
273  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
274  Using Arduino / Programming Questions / Re: using analog pins as digital on: April 10, 2012, 09:59:33 am
thank you
275  Using Arduino / Programming Questions / Re: using analog pins as digital on: April 10, 2012, 09:44:41 am
int greenled = 1; for a digital pin

what phrase do we do for an analog a0 pin?
thank you
276  Using Arduino / Programming Questions / using analog pins as digital on: April 10, 2012, 09:26:23 am
hi,
i would like to use the analog input pins as digital pins, just wondering what to do is the structure section with regards to the Int characters, how to change the pin o analog to digital, cant see anything in the reference section
thank you
277  Using Arduino / Programming Questions / Re: help with my program please on: April 09, 2012, 01:58:46 pm
thanks paul will read up on boolean variable
278  Using Arduino / Programming Questions / Re: help with my program please on: April 09, 2012, 01:36:54 pm
hi paul yes stop switch to act as a toggle switch, if the stop is made stops gas valve, on again gas valve on
thank you
279  Using Arduino / Programming Questions / Re: help with my program please on: April 09, 2012, 01:18:46 pm
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 emstopled = 10;         // emergency stop switch led
int greenled = 9;           // green led lights if fan1 and fan2 are low connected to pin 9. healthey fan1 and fan2
int redled = 8;             // red led lights if fan 1 or fan2 are high connected to pin 8.  (sounds an alarm)
int relay = 7;              // gas relay
int buz = 6;                // buzzer sounds if fault
int emstop = 5;             // emergency stop switch input.
int mute = 4;               // mute buzzer
int fan2 = 3;               // fan switch is connected to pin 3
int fan1 = 2;               // fan switch is connected to pin 2
int fan1val;                // var for reading the pin status
int fan2val;                // var for reading the pin status
int muteval;                // var for reading the pin status
int emstopval;              // var for reading pin status.


void setup(){   
  pinMode(greenled, OUTPUT);      // Set the Greenlled as op.
  pinMode(redled, OUTPUT);        // Set the LED pin 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(mute, INPUT);           // Set the switch pin as 1p.
  pinMode(emstop, INPUT);         // Set the switch pin as 1p.
  pinMode(emstopled, OUTPUT);     // Set the switch pin as 1p
}


 void loop(){
  fan1val = digitalRead(fan1);            // read input value and store it in fan1
  fan2val = digitalRead(fan2);            // read input value and store it in fan2
 
  if ((fan1val == LOW) && (fan2val == LOW))
  {                                       // check if both inputs show fan OK (Switch is pressed)
    digitalWrite(greenled, HIGH);         // turn green on
    digitalWrite(relay, HIGH);            // turn on gas relay.
    digitalWrite(buz,LOW);                // buzzer off, no error
    digitalWrite(redled,LOW);             // red led off no fault
  } else{                                 // we do not need to test the opposite do the following.
    digitalWrite(greenled, LOW);          // turn green OFF 
    digitalWrite(redled, HIGH);           // red led on
    digitalWrite(relay, LOW);             // gas valve off
    digitalWrite(buz, HIGH);              // buzzer on
    }   

   emstopval = digitalRead(emstop); 
 
 if (emstopval == LOW)
 {digitalWrite(emstopled, HIGH);         //emergency stop made, lights led, and gas valve off.
  digitalWrite(relay, LOW);              // gas valve off ******(probable does turn off, but when program loops gas is turned on again in the top statement)*******                       

 }else{
             
   digitalWrite(emstopled, LOW);         // emergency stop led
 }}

sorry ive cleaned it up more clear, what im trying to do is when the stop is made the gas valve turns off (stop out gas on again), but when the program loops again the relay is turned on again
280  Using Arduino / Programming Questions / Re: help with my program please on: April 09, 2012, 12:11:40 pm
just when i think im getting somewhere another problem,

in the last statement, emstop (emergency stop) this should turn off gas valve, but obviously as it loops the gas valve is turned back on,
is there a way round this?
thank you


   emstopval = digitalRead(emstop);  
 if (emstopval == LOW){
 digitalWrite(emstopled, HIGH);
                                                     //emergency stop made, gas valve off buzzer sounds.
 }else{
      
   digitalWrite(relay, LOW);                // gas valve off but turns on again as program loops
    }
 }


281  Using Arduino / Programming Questions / Re: help with my program please on: April 09, 2012, 10:45:55 am
great thanks for the help all sorted
282  Using Arduino / Programming Questions / Re: help with my program please on: April 09, 2012, 09:37:31 am
 
Code:
 
  emstopval == digitalRead(emstop); 
 if (emstop == LOW)
{
   digitalWrite(emstopled, HIGH);     //emergency stop made, gas valve off buzzer sounds. **** wont change to a high****



hi, works both ways but, it was this part i was having trouble with?
283  Using Arduino / Programming Questions / Re: help with my program please on: April 09, 2012, 09:20:18 am
Code:
emstopval == digitalRead(emstop);  
 if (emstop == LOW)
{
   digitalWrite(emstopled, HIGH);     //emergency stop made, gas valve off buzzer sounds. **** wont change to a high****

  } }  
  

hi dxwood thanks for the help, not a million miles from you im from andover, i noticed that first error and fixed it but still no joy? i shortened the (emergencystop to emstop a bit confusing)
thanks
284  Using Arduino / Programming Questions / help with my program please on: April 09, 2012, 08:22:03 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 emstopled = 10;  // emergency stop switch led
int greenled = 9;           // green led lights if fan1 and fan2 are low connected to pin 9. healthey fan1 and fan2
int redled = 8;             // red led lights if fan 1 or fan2 are high connected to pin 8.  (sounds an alarm)
int relay = 7;              // gas relay
int buz = 6;                //buzzer sounds if fault
int emstop = 5;      // emergency stop switch input.
int mute = 4;               // mute buzzer
int fan2 = 3;               // fan switch is connected to pin 3
int fan1 = 2;               // fan switch is connected to pin 2
int fan1val;                // var for reading the pin status
int fan2val;                // var for reading the pin status
int muteval;                // var for reading the pin status
int emstopval;       // var for reading pin status.


void setup(){   
  pinMode(greenled, OUTPUT);      // Set the Greenlled as op.
  pinMode(redled, OUTPUT);        // Set the LED pin 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(mute, INPUT);           // Set the switch pin as 1p.
  pinMode(emstop, INPUT);  // Set the switch pin as 1p.
  pinMode(emstopled, OUTPUT); // Set the switch pin as 1p
}


 void loop(){
  fan1val = digitalRead(fan1);            // read input value and store it in fan1
  fan2val = digitalRead(fan2);            // read input value and store it in fan2
 
  if ((fan1val == LOW) && (fan2val == LOW))
  {                                       // check if both inputs show fan OK (Switch is pressed)
    digitalWrite(greenled, HIGH);         // turn green on
    digitalWrite(relay, HIGH);            // turn on gas relay.
    digitalWrite(buz,LOW);                // buzzer off, no error
    digitalWrite(redled,LOW);             // red led off no fault
  } else{                                 // we do not need to test the opposite do the following.
    digitalWrite(greenled, LOW);          // turn green OFF 
    digitalWrite(redled, HIGH);           // red led on
    digitalWrite(relay, LOW);             // gas valve off
    digitalWrite(buz, HIGH);              // buzzer on
    }   

  emstopval == digitalRead(emstop); 
 if (emstop == LOW)
{
   digitalWrite(emstopled, HIGH);     //emergency stop made, gas valve off buzzer sounds. **** wont change to a high****




hi this is my first program after a couple of days im really stuck, i would like to start another if command with instructions to follow but wont work
can anybody help please
thank you
285  Using Arduino / General Electronics / npn transistor question on: April 07, 2012, 04:42:53 am
hi
i want to use this surface mount npn transistor, and i want to work out the base resistor to use, could someone tell me the max voltage and current that can be applied to the base to turn it on? and what symbols to look for?
thank you

http://www.rapidonline.com/pdf/47-3372.pdf
Pages: 1 ... 17 18 [19] 20 21 22