-->
Page 1 of 1

AnalogWrite have a bug?

PostPosted: Tue Nov 01, 2016 1:42 am
by gorec2005
Hi!
help please...
this sketch have wdt reset! - try it please...
it's my fault or analogWrite bug?

Code: Select allint led = 15;

void setup() {
pinMode ( led, OUTPUT );
digitalWrite ( led, 0 );
}

void loop() {
analogWrite ( led, 1 );
delay(1000);
analogWrite ( led, 1000 );
delay(1000);
}

Re: AnalogWrite have a bug?

PostPosted: Tue Nov 01, 2016 6:06 pm
by Barnabybear
Hi,
Code: Select allanalogWrite ( led, 1000 );

the max value for analogWrite is 255. Try this:
Code: Select allanalogWrite ( led, 255 );

Re: AnalogWrite have a bug?

PostPosted: Tue Nov 01, 2016 9:49 pm
by rudy
Code: Select allanalogWrite ( led, 1000 );

Works for me. And no wdt reset.

Code: Select allint led = 15;

void setup() {
pinMode ( led, OUTPUT );
digitalWrite ( led, 0 );
}

void loop() {
analogWrite ( led, 1 );
delay(1000);
analogWrite ( led, 1000 );
delay(1000);
analogWrite ( led, 512 );
delay(1000);
analogWrite ( led, 255 );
delay(1000);
}


I would try putting WiFi.disconnect(); at the top. Do you have wdt resets when you run any other code? Maybe you have poor power supply regulation on the 3.3V line.