int analog_pin = 7;
float val;
int red_led = 9;

void setup() {
}

void loop() {
  val = 1024 - analogRead(analog_pin);
  int Level = map (val ,0 ,1024, 0 , 255);
  analogWrite(red_led, Level);

}