Skip to content

Max value for analogWrite(pin, value) ? #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
redflag2k opened this issue May 21, 2015 · 2 comments
Closed

Max value for analogWrite(pin, value) ? #295

redflag2k opened this issue May 21, 2015 · 2 comments

Comments

@redflag2k
Copy link

First of all, My environment is Arduino 1.6.4 with ESP8266 xxx.json (Latest release), ESP-12 version
and I am trying to test analogWrite for PWM.

I found my led strip is so dark at following code.

analogWrite(GPIO12, 255);

So, I changed the value 255 to 999. then the led strip became more brighter.

My question is that...

What is the maximum value of PWM? (In arduino uno, 255 is maximun value, because arduino is 8bit MCU)

My guess is that... In ESP8266, the maximum value of analogWrite is 0xFFFF (=65,535), because ESP8266 has 32bit cpu core.

Is my guessing right?

@igrr
Copy link
Member

igrr commented May 21, 2015

Actually it's defined as PWMRANGE:
#define PWMRANGE 1023

https://github.com/esp8266/Arduino/blob/HEAD/hardware/esp8266com/esp8266/cores/esp8266/Arduino.h#L47

@redflag2k
Copy link
Author

Thank you for your clear reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants