Skip to content
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

PWMRANGE error #162

Open
DziveQ opened this issue Feb 2, 2022 · 3 comments
Open

PWMRANGE error #162

DziveQ opened this issue Feb 2, 2022 · 3 comments

Comments

@DziveQ
Copy link

DziveQ commented Feb 2, 2022

Hi. I'm trying to use example simple_led and the only thing I changed was SSID name and password. When I'm uploading, I'm getting this error:

C:\Users\kacpe\AppData\Local\Temp\arduino_modified_sketch_215244\simple_led_accessory.c: In function 'led_update':
simple_led_accessory.c:67:13: error: 'PWMRANGE' undeclared (first use in this function)
67 | int pwm = PWMRANGE - (int) (led_bri * 1.0 * PWMRANGE / 100.0 + 0.5f);
| ^~~~~~~~
C:\Users\kacpe\AppData\Local\Temp\arduino_modified_sketch_215244\simple_led_accessory.c:67:13: note: each undeclared identifier is reported only once for each function it appears in
exit status 1
'PWMRANGE' undeclared (first use in this function)

I'm using correct Port and Board settings (it's working with other sketches)

@kuznetsov-m
Copy link

Guys, I have the same problem.
Googling for the PWMRANGE variable gave me the following issue:

1.) the change of PWMRANGE via analogWriteRange(new_range) is not possible!
-> if you set 1000 or 255 for example there ist no change -> only 1023.

This issue has nothing to do with this project. However, I decided to try redefining the PWMRANGE variable.
I just added a declaration int PWMRANGE = 1023; to the method led_update()

void led_update() {
	if (led_power) {
		int PWMRANGE = 1023;     // redefining PWMRANGE here
		int pwm = PWMRANGE - (int) (led_bri * 1.0 * PWMRANGE / 100.0 + 0.5f);
		analogWrite(PIN_LED, pwm);
		printf("ON  %3d (pwm: %4d of %d)\n", led_bri, pwm, PWMRANGE);
	} else {
		printf("OFF\n");
		digitalWrite(PIN_LED, HIGH);
	}
}

This is a very dirty solution. But it allowed me to compile the example.

@dani34dag
Copy link

dani34dag commented Sep 9, 2022

Con esta corrección me ha funcionado, el problema es que al poner el 100% de brillo se apaga, y al poner 0% se enciende del todo, alguien sabe algo? en definitiva funciona del revés

Lecturas monitor serie:
(en este estado la barrita esta la luz al 100% de brillo, pero se apaga del todo)
ON 100 (pwm: 0 of 1023)

(en este estado la barrita esta la luz al 0% de brillo, pero se enciende del todo)
ON 0 (pwm: 1023 of 1023)
OFF

@FrenchBen
Copy link

This is due to an old reference, for the esp8266 library that was since updated.
#define PWMRANGE 1023 was removed
esp8266/Arduino#7456

In the default library this was set to the upstream value of 255:
https://github.com/esp8266/Arduino/blob/master/cores/esp8266/core_esp8266_wiring_pwm.cpp#L29

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

4 participants