Show Posts
Pages: 1 ... 17 18 [19] 20 21
271  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
272  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
273  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
274  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
275  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
276  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
    }
 }


277  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
278  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?
279  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
280  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
281  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
282  Using Arduino / Programming Questions / Re: how to toggle an op on: April 06, 2012, 03:21:19 pm
hi AWOL, i would like to learn make a mute button that would turn on/off a buzzer circuit, momentary push switch that will switch on /off an output
thank you
283  Using Arduino / Programming Questions / how to toggle an op on: April 06, 2012, 02:44:37 pm
hi,
i would like to learn how to toggle an op, for muting, a circuit i have, has anybody seen any tutorials or examples of code i could try to use and learn from.
thank you
284  Using Arduino / Programming Questions / Re: quick question on: April 05, 2012, 07:09:09 am
i know this because im not using a serial monitor, ive got it in a circuit switching 0v into pins 2 and 3, and leds on 8,9.

ok now sorted missing { should be .....     } else {

i sort of understand the statment  if (fan1val == LOW && fan2val == LOW) do this

"else"

do this other function..

thanks for the help and everybody patience
285  Using Arduino / Programming Questions / Re: quick question on: April 05, 2012, 06:32:31 am
Code:
/*
 *  2 switches monitoring two fans, healthly if both switches are low output switches a relay, if any input high an alarm sounds no output to relay.
 */
 
int greenled = 9;            // green led lights if fan1 and fan2 are low connected to pin 9. (operates a relay)
int redled = 8;              // red led lights if fan 1 or fan2 are high connected to pin 8.  (sounds an alarm)
int fan1 = 3;                 // fan switch is connected to pin 3
int fan2 = 2;                 // fan switch is connected to pin 2
int fan1val;                      // variable for reading the pin status
int fan2val;                      // variable for reading the pin status


void setup(){   
  pinMode(greenled, OUTPUT);      // Set the Greenlled pin as output-- this will light up if i get a low at fan1+fan2
  pinMode(redled, OUTPUT);        // Set the LED pin as output-- this will light up if i get a low at fan1+fan2
  pinMode(fan1, INPUT);           // Set the switch pin as input
  pinMode(fan2, INPUT);           // Set the switch pin as input
}


 void loop(){
  fan1val = digitalRead(fan1);                           // read input value and store it in val
  fan2val = digitalRead(fan2);                           // read input value and store it in val
  if (fan1val == LOW && fan2val == LOW) {                 // check if both inputs show fan OK (Switch is pressed)
    digitalWrite(greenled, HIGH);                         // turn green on
    digitalWrite(redled, LOW);                             //  .. and red off red*** RED DOES NOT TURN OFF, IT STAYS ON ALL THE TIME.
  } else;                                                // we do not need to test the opposite -  we do not light green, we light red
    digitalWrite(greenled, LOW);                            // turn green OFF  ***does turn off***
    digitalWrite(redled, HIGH);                                // .. and red on  **** is Red**
  }



there seems to be an error with the red led as it stays on all the time, i have tripple checked my circuit im getting the correct inputs two lows, the redled should turn off, it stays on all the time? any ideas?
thanks 
Pages: 1 ... 17 18 [19] 20 21