Show Posts
Pages: 1 ... 18 19 [20] 21 22
286  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
287  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
288  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
289  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 
290  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.
291  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?
292  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.
293  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.
294  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
295  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.
296  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
  }
}
297  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
298  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 
299  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  
300  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
Pages: 1 ... 18 19 [20] 21 22