const int potPin = A0;
const int ledPin = 9;
int potValue = 0;
int pwmValue = 0;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
potValue = analogRead(potPin);
pwmValue = map(potValue, 0, 1023, 0, 255);
analogWrite(ledPin,pwmValue);
Serial.print("Potentiometer value:");
Serial.print(potValue);
Serial.print("Pwm: ");
Serial.println(pwmValue);
delay(1000);
}