int pwm_id = 0; int delay_us = 200000; int freq = 781; //HZ int value = 0; void setup() { int step = 0; step = pwmfreq_set(pwm_id, freq); printf("PWM%d set freq %d and valid duty cycle range [0, %d]\n", pwm_id, freq, step); if (step > 0) { printf("PWM%d test with duty cycle %d\n", pwm_id, value); analogWrite(pwm_id, value); } } void loop() { value += 5; if (MAX_PWM_LEVEL < value) value = 0; delayMicroseconds(delay_us); printf("PWM%d test with ducy cycle %d\n", pwm_id, value ); analogWrite(pwm_id, value); }