int ledPin = 9;
int adcValue; // adcValue
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT); // LED pin is output
}
void loop() {
// put your main code here, to run repeatedly:
adcValue = analogRead(A0); // turn analog of A0 to digital
// Map analog to the 0-255 range, and works as PWM duty cycle of ledPin port
analogWrite(ledPin, map(adcValue, 0, 1023, 0, 255));
}