Go Down

Topic: If statements. (Read 468 times) previous topic - next topic

mlgardner

Dec 01, 2009, 12:30 am Last Edit: Dec 01, 2009, 12:30 am by mlgardner Reason: 1
I currently have a code to take a reading from an analogue and depending on the value it will light an LED simply.

I currently am using:

Code: [Select]
// then do the Play Led
  val = analogRead(analogPinPlay);
  if (val > 400) {
    digitalWrite(ledPinPlay, HIGH);
  }
  else {
    //
    digitalWrite(ledPinPlay, LOW);
   }


I now want to set the value to be a range so that:
value > 400 and less 600.

and tried to write it as

Code: [Select]
  // then do the Play Led
  val = analogRead(analogPinPlay);
  if (val > 400; val < 600) {
    digitalWrite(ledPinPlay, HIGH);
  }
  else {


but when i verify it the line doesnt work.

Can anyone help me here please :)

Thanks in advance.

crimony

Code: [Select]

// then do the Play Led
  val = analogRead(analogPinPlay);
  if ((val > 400) && (val < 600)) {
    digitalWrite(ledPinPlay, HIGH);
  }
  else {

mlgardner

Perfect.

Thankyou very much.


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy