Show Posts
Pages: 1 ... 18 19 [20] 21
286  Using Arduino / Programming Questions / Re: quick question on: April 05, 2012, 04:57:06 am
hi awal,
yes i had already worked it out my program has now "compiled" and working was just trying to work out how use tags when posting code
thanks very much for your help, wish i had started to learn programming years ago, its just so nteresting love it.
287  Using Arduino / Programming Questions / Re: quick question on: April 05, 2012, 04:40:45 am
ok will do as requested,

bzzzt does that mean wrong?
288  Using Arduino / Programming Questions / Re: quick question on: April 05, 2012, 04:02:41 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 = 12;            // green led lights if fan1 and fan2 are low connected to pin 12. (operates a relay)
int redled = 11;              // red led lights if fan 1 or fan2 are high connected to pin 11.  (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
  } else )                                                 // we do not need to test the opposite -  we do not light green, we light red
    digitalWrite(greenled, LOW);                            // turn green
    digitalWrite(redled, HIGH                                // .. and red on
  }
}


thanks for the help but when i load the program i get an error "primary expression before token, what does this mean??
thank you


Moderator edit: Please use [code] [/code] tags when posting code.
289  Using Arduino / General Electronics / Re: how to switch a power circuit. on: April 05, 2012, 03:49:22 am
hi jack, thanks but id prefer to do it electronically.
290  Using Arduino / General Electronics / how to switch a power circuit. on: April 05, 2012, 03:24:44 am
hi
im currently making a project, it has a regulated power supply up to 1a 5v, a uno inside i would like to turn on the power via a momentary push switch on the front panel, can someone recommend me a circuit for doing this?
thank you
291  Using Arduino / Programming Questions / Re: quick question on: April 04, 2012, 03:34:43 pm
thanks very much Msquare, i will finish this tomorrow really appreciate everybody help so kind.
292  Using Arduino / Programming Questions / Re: quick question on: April 04, 2012, 03:03:06 pm
what my problem is an absolute mental block of getting more than 1 input/output in a program a, this is my first project i havnt worked out the logic in the loop yet.

/*
 *  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 = 12;            // green led lights if fan1 and fan2 are low connected to pin 12. (operates a relay)
int redled = 11;              // red led lights if fan 1 or fan2 are high connected to pin 11.  (sounds an alarm)
int fan1 = 3;                 // fan switch is connected to pin 3
int fan2 = 2;                 // fan switch is connected to pin 2
int val;                      // 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(){
  val = digitalRead(fan1);           // read input value and store it in val
  val = digitalRead(fan2);           // read input value and store it in val 
  if (val == LOW) {                 // check if the button is pressed
    digitalWrite(greenled, LOW);     // turn LED on
  }
  if (val == HIGH) {              // check if the button is not pressed
    digitalWrite(greenled, LOW);    // turn LED off
  }
}
293  Using Arduino / Programming Questions / Re: quick question on: April 04, 2012, 02:29:29 pm
i got it from this tutorial here http://www.ladyada.net/learn/arduino/lesson5.html
294  Using Arduino / Programming Questions / Re: quick question on: April 04, 2012, 02:24:13 pm
ok here goes, i would like to monitor 3 or more inputs using switchpins, then use the data to make outputs using the digitalwrite function,

thank you 
295  Using Arduino / Programming Questions / Re: quick question on: April 04, 2012, 01:43:54 pm
hi paul
not sure that would work with what im trying to do, my 1st project was to monitor 3 inputs if all the same state then i get one output to drive a relay really confused because in all the examples they seem to contain just one led and input would like to monitor multi inputs,  and use logic to drive relays

/*
 *  Switch and LED test program
 */
 
int ledPin = 12;                // LED is connected to pin 12
int switchPin = 2;              // switch is connected to pin 2
int val;                        // variable for reading the pin status


void setup() {
  pinMode(ledPin, OUTPUT);      // Set the LED pin as output
  pinMode(switchPin, INPUT);    // Set the switch pin as input
}


void loop(){
  val = digitalRead(switchPin);   // read input value and store it in val
  if (val == LOW) {               // check if the button is pressed
    digitalWrite(ledPin, HIGH);   // turn LED on
  }
  if (val == HIGH) {              // check if the button is not pressed
    digitalWrite(ledPin, LOW);    // turn LED off
  }
}

its so frustrating, i under stand all of this program, but i  really want to  monitor 3 + inputs on multi switchpins. and have different outputs using logic statments  
296  Using Arduino / Programming Questions / Re: quick question on: April 04, 2012, 01:21:38 pm
hi paul
not sure that would work with what im trying to do, my 1st project was to monitor 3 inputs if all the same state then i get one output to drive a relay really confused because in all the examples they seem to contain just one led and input would like to monitor multi inputs,  and use logic to drive relays
297  Using Arduino / Programming Questions / Re: quick question on: April 04, 2012, 04:52:46 am
ok will give my head a good scratch and think about it
thank you
298  Using Arduino / Programming Questions / Re: quick question on: April 04, 2012, 04:08:21 am
hi paul thanks for the help
cant i call them...


int val1, and assign it to  int switchPin = 2
int val2,                        int switchPin = 3
int val3,                        int switchPin = 4

then use the val1,2,3 in logic statement later ?

thank you
299  Using Arduino / Programming Questions / quick question on: April 04, 2012, 03:19:12 am
hi,
im trying to learn logic statments, how do i assign the int val's to the three switch pins for my logic statments??

9a6PR2hU
Quote
int ledPin = 12;                // LED to pin 12
int ledpin = 11;                // led to pin 13
int switchPin = 4;              // switch is connected to pin 4
int switchPin = 3;              // switch is connected to pin 3
int switchPin = 2;              // switch is connected to pin 2
int val;                        // variable for reading the pin status
int val;                        // how do i assign these two pin 3???
int val;                        // how do i assign this to pin 2???


thank you
300  Using Arduino / Programming Questions / Re: make an output latch? on: April 03, 2012, 02:57:31 am
thanks for the help
Pages: 1 ... 18 19 [20] 21