error: 'val' was not declared in this scope

Just got my arduino and trying to attach a photo-resistor to control a LED. The code is from the Arduino-book:

#define LED 13

int value = 0;

void setup() {
pinMode(LED, OUTPUT);
}

void loop() {

val = analogRead(0);

digitalWrite(13, HIHG);

delay(val);

digitalWrite(13, LOW);

delay(val);

}

I get this error when compiling:

In function 'void loop()':
error: 'val' was not declared in this scope

Where did I go wrong?

You are declaring it as "value", then calling "val"

#define LED 13

int [glow]value[/glow] = 0;

void setup() {
 pinMode(LED, OUTPUT);
}

void loop() {

 [glow]val[/glow] = analogRead(0);

 digitalWrite(13, HIHG);

 delay([glow]val[/glow]);

 digitalWrite(13, LOW);

 delay([glow]val[/glow]);

}

For it to work the label has to be the same :slight_smile:

You're a star! Thank you, beige!