const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int analogOutPin = 9; // Digital pin 9 int potValue = 0; // value read from the pot int outputPWM = 0; // value output to the PWM (analog out) int Duty = 0; int delaytime = 1000; void setup() { Serial.begin(9600); } void loop() { // read the analog in value: potValue = analogRead(analogInPin); // map it to the range of the analog out: outputPWM = map(potValue, 0, 1023, 0, 255); Duty = map(outputPWM, 0, 255, 0, 100 ); // change the analog out value: analogWrite(analogOutPin, outputPWM); // print the results to the Serial Monitor: Serial.print("Pot Value = "); Serial.print(potValue); Serial.print("\t Output PWM = "); Serial.print(outputPWM); Serial.print("\t Duty = "); Serial.println(Duty); delay(delaytime); // change the frequency }