Simple Analogue Input Question

I'm working through some of the examples in the "Getting Started with Arduino" book. The first analogue input sketch is very simple. It uses an LED as the actuator and a photoresistor as the analogue sensor. The brighter the light, the slower the LED blinks. This is the sketch:

//Example 07a: Blink an LED at a rate specified by the value of the analogue input.

define LED 13 // the pin for the LED

int val = 0; // variable used to store the value coming from the sensor

void setup() { pinMode(LED, OUTPUT); // LED is the output

}

void loop (){

val = analogRead (0); // read the value from the sensor

digitalWrite(13, HIGH); // turn the LED on

delay(val); // stop the program for some time

digitalWrite(13, LOW); // turn the LED off

delay(val); // stop the program for some time

}

Is it possible to get the process reversed, so that the LED blinks faster as the amount of light increases? I tried reversing the digitalWrite commands so that the first was digitalWrite(13, LOW) and vice versa but that didn't do anything.

The sketch is so simple, I don't know what else to change.

The sketch is so simple, I don't know what else to change.

Read the comments of the sketch. Which statements control the flow the program: digitalWrite() or delay()?

I tried messing with the delay(val) commands. I changed the sequence so that they came before the digitalWrite commands; added a negative sign in front of the val and also tried adding a negative sign in front of the zero in the analogRead(0) command. That didn't change anything.

delay(1023 - val); ;)