'pulseio' object has no attribute 'PWMOut'

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Marson
 
Posts: 3
Joined: Mon Nov 01, 2021 8:13 am

'pulseio' object has no attribute 'PWMOut'

Post by Marson »

I have a Feather RP2040 and I'm trying to run this code

Code: Select all

import pulseio
buzzer = pulseio.PWMOut(board.D24, variable_frequency=True)
...loop for reading distance and buzzing a piezo...
but I'm getting

Code: Select all

AttributeError: 'module' object has no attribute 'PWMOut'
I've tried different pins, but get the same error on all of them. Any ideas?

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: 'pulseio' object has no attribute 'PWMOut'

Post by dastels »

The API seems to have changed since that code was written. See https://circuitpython.readthedocs.io/en ... le-pulseio.

Also, make sure all your libraries/modules are up to date from the most recent bundle release. I advise deleting everything in CIRCUITPY/lib, emptying trash as appropriate for your OS, then copying files/directories from the bundle to CIRCUITPY/lib as required.

Dave

User avatar
Marson
 
Posts: 3
Joined: Mon Nov 01, 2021 8:13 am

Re: 'pulseio' object has no attribute 'PWMOut'

Post by Marson »

Thanks for the quick reply, dastels. It looks like pulseio isn't what I want then. I did some more digging and tried the pwmio module using pwmio.PWMOut(). The code runs fine now, and I'm getting square waves at the expected pin!

Unfortunately I'm not getting any sound from the piezo, even with the code from the first block on this page. I'll have to try a different component. (Interesting that the text mentions pulseio while the code is using pwmio. I'm guessing the page might have been only partially updated at some point.)
https://learn.adafruit.com/annoy-o-mati ... oy-o-matic

User avatar
Marson
 
Posts: 3
Joined: Mon Nov 01, 2021 8:13 am

Re: 'pulseio' object has no attribute 'PWMOut'

Post by Marson »

The piezo issue was a bad connection. The wires are so small on the mini piezo, I didn't make a good connection when I tried to crimp pin terminals to it. Everything is working as I'd intended now. :D

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: 'pulseio' object has no attribute 'PWMOut'

Post by dastels »

Excellent :)

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”