int ledPin = 8;
int potentiometerPin = A0;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int potValue = potentiometerValue();
int fadeValue = map (potValue, 0, 1023, 0, 255);
analogWrite(ledPin, fadeValue);
delay(30);
}
int potentiometerValue ()
{
int val = analogRead(potentiometerPin);
return val;
}