#define motor_pin 3 #define pot_pin A0 void setup() { pinMode(motor_pin, OUTPUT); } void loop() { int a = analogRead(pot_pin); int b = (a * 255) / 1023; analogWrite(motor_pin, b); }