Pages: [1]   Go Down
Author Topic: If statements.  (Read 394 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
// 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:
  // 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 smiley

Thanks in advance.
« Last Edit: November 30, 2009, 06:30:42 pm by mlgardner » Logged

Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 99
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perfect.

Thankyou very much.

Logged

Pages: [1]   Go Up
Jump to: