Light Sensor and LED Problem - LilyPad

Hello,
I want to link the light sensor of my LilyPad to my LED, so that the LED gets lighter when the light around gets darker. I tried this code:

int light=A6;
int lightval=0;
int ledlight=9;
int brightness=0;

void setup() {
 pinMode(ledlight, OUTPUT);
 pinMode(light, INPUT);
}
void loop() {
  lightval= analogRead(light);
  lightval /= 4
  brightness= 255-lightval;
  analogWrite(ledlight, brightness);
}

But this code gives me the exact opposite result than wished, the LED goes darker if I cover the light sensor.
When I tried to reverse the value of brightness by setting brightness to lightval, the LED was just on all the way through.
Now what can I do?

(Edit)
The LilyPad is wired like this.
http://digital.digitalspyeye.com/uploadfiles/digitaldigitalspyeyecom-1308941224/sparkfun-unveils-new-diy-arduino-prototyping-kits-protosnap-video-_1.jpg

Thanks

Part of your problem may be that analogRead returns a ten bit number, but analogWrite takes an eight bit number.

Thanks for the fast reply, so what would an example be for both an eight bit number or ten bit number and how could I solve that problem?

Imagine that "lightval" has the value 1007.
What value does that give to "brightness"?

You haven't told us how the LDR or LED are wired.

It would make approximately -750, so I divided lightval by 4 before calculating brightness, which I expected to give me the right outcome, but the outcome stayed the same.

If the input from the light sensor is 1007, does that mean, there is much light? Because then the calculation would be like following:

lightval = 1007 / 4 = 252
brightness = 255 - 252 = 3

Which would mean, that the brightness gets lower while the input gets higher, but the brightness instead decreases, when the input decreases.

If the input from the light sensor is 1007, does that mean, there is much light?

I don't know, which is why I asked how it was wired.

It isn't wired it's just the LilyPad in the thing it came in, like this.
http://digital.digitalspyeye.com/uploadfiles/digitaldigitalspyeyecom-1308941224/sparkfun-unveils-new-diy-arduino-prototyping-kits-protosnap-video-_1.jpg

You've got the hardware; why don't you tell us whether the reading goes up or down as the light gets brighter?

With the sketch right now, the diode gets brighter nicely when the light gets brighter.
But of course I want the diode to increase in brightness when the light gets darker.
So it works well- just the other way round. It´s supposed to be like a night light.

What does this do:

const int light=A6;
const int ledlight=9;

void setup() 
{
}

void loop() 
{
  int lightval = analogRead(light) / 4;
  int brightness = lightval;
  analogWrite(ledlight, brightness);
}

?

Note that you don't set the pinMode of analogue input pins, and PWM output pins don't need them either, the analogWrite sets the mode.

Note: Please don't edit earlier posts to reflect the new state of code, it makes the thread hard to follow - just put the amended code in a new post.