int potPin = 2; int potVal = 0; int motorPin = 9; void setup() { Serial.begin(9600); pinMode(potPin, INPUT); pinMode(motorPin, OUTPUT); } void loop() { potVal = analogRead(potPin); int fanSpeed = map(potVal, 0, 1023, 0, 255); Serial.println(potVal); delay(400); analogWrite(motorPin,fanSpeed); Serial.print("Your fan speed is: "); Serial.print(fanSpeed); }