const int pinPot = A0;
const int pinLED = 9;
void setup() {
pinMode(pinPot, INPUT);
pinMode(pinLED, OUTPUT);
}
int sensor = 0;
int brightness = 0;
void loop() {
sensor = analogRead(pinPot);
brightness = map(sensor, 0, 1023, 0, 255);
analogWrite(pinLED, brightness);
}