Go Down

Topic: If statements. (Read 429 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