You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "<stdin>", line 34, in <module>
File "/lib/buzzer_music.py", line 263, in tick
AttributeError: 'PWM' object has no attribute 'duty_u16'
The lack of said attribute can be confirmed by:
from machine import Pin, PWM
p = PWM(Pin(12))
print(dir(p))
# returns ['__class__', 'deinit', 'duty', 'freq', 'init'] on ESP8266 platform
In order to make it work on ESP8266 while retaining Pico compatibility this can be done:
if hasattr(pwm, 'duty_u16'):
pwm.duty_u16(self.duty)
else:
pwm.duty(self.duty)
On Wemos D1 mini (ESP8266) I am getting:
The lack of said attribute can be confirmed by:
In order to make it work on ESP8266 while retaining Pico compatibility this can be done:
While testing with D1 mini buzzer shield (https://www.wemos.cc/en/latest/d1_mini_shield/buzzer.html) I also had to lower duty (set to 100) as the default value (2512) only produced almost inaudible clicks.
The text was updated successfully, but these errors were encountered: