int potPin = A0; // potentiometer pin
int motorPin = 9; // motor control pin
void setup() {
pinMode(potPin, INPUT); // set potentiometer pin as input
pinMode(motorPin, OUTPUT); // set motor control pin as output
}
void loop() {
int potValue = analogRead(potPin); // read potentiometer value
int speed = map(potValue, 0, 1023, 0, 255); // map potentiometer value to PWM range
analogWrite(motorPin, speed); // set PWM duty cycle for motor speed
}