int pwm;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
pwm = analogRead(0); // читаем с потенциометра на порту А0
pwm = map(pwm, 0, 1023, 0, 255); // переводим значения в 0-255
pwm = constrain(pwm, 0, 255); // ограничиваем значения
analogWrite(3, pwm); // выводим ШИМ на 3 пин
//Serial.println(pwm);
}