/* Reading a potentiometer on analog pin A0 and printing out the value and controls the PWM of an LED */ int potValue = 0; int potPin = A0; int pwmValue = 0; int ledPin = 6; void setup(){ Serial.begin(9600); pinMode(ledPin, OUTPUT); } void loop(){ potValue = analogRead( potPin ); Serial.print("potValue = "); Serial.println(potValue); pwmValue = map(potValue, 0, 1023, 0, 255); analogWrite(ledPin, pwmValue); delay(100); }