Lost looking for PWM library


I'm new to Arduino and the Due, but I have a good deal of experience programming 8-bit AVRs in C.

I'm using the Due because I need the additional speed and capabilities.

Right now I'm trying to program a PWM channel with a base frequency somewhere in the 5kHz-10kHz range... well withing the capabilities of the SAM3X.

In may searches I have found mention of a library called PWM.h that sounds like it will do exactly what I need. I have also found posts that suggest making modifications to variant.h will get me where I need to go.

I would like to look into both of these options, but I'm having trouble finding either. The PWM library I think is an add-on, but I'm not sure where to find it. Variant.h seems to be part of the base library structure, but where does the variant.h library live? I can't find it on my mac with spotlight?



Go to the Arduino application. Alt click and choose "Show Contents" from the drop down menu.
Then in the window type in PWM in the search box at the top of the window. You will then see them all.

Thanks for the quick reply.

Those instructions don’t seem to be working for me. I wonder if it is because I am on a Mac?

When I go to the apps folder, I click on the Arduino.app with my control key held down. I get a menu with the option “Show Package Contents”… which I then chose.

Then the following window pops up.

I don’t see the stuff there, and spotlight doesn’t help either? What have I done wrong?



Yes I am on a mac as well. You are not doing the search in the top right of the window.

Then in the window type in PWM in the search box at the top of the window. You will then see them all.

This is what I get:-

Here's a library I wrote for the Due (link below). It allows you to setup up to two PWM channels each with a unique frequency. Login to get the library. Example included below. Good luck.

Hey Random!
I had just found your lib on my own and installed it. Works great!!! Thanks so much.

I'm still not finding anything in the finder per your instructions... but now my PWM issue appears solved... so I'm off to find the next wall to bang my head against. This time with a slightly better understanding of the landscape. Thanks so much for your help. It is much appreciated.




Random, I noticed in reading over the SAM3X datasheet that there are some functions in the PWM register that are designed to allow you to time A2D readings with your PWM wave form. Have you played with this feature at all? I'm gonna need it as my PWM is going to drive some Mosfets which are in turn driving a motor which will be broadcasting PWM noise straight into the ear of my sensor!


I think I'm making some progress. I found the verbose compiler option in preferences, and that got me looking in the hidden /var directory.

I switched out of finder and into X11 and I'm seeing a lot more.

Thanks for your help.

I’m still not finding anything in the finder per your instructions…

How have you got your finder preferences set?