Using PWM as anaolgue comparison

I am thinking about a project that will use an analogue comparator to detect sound.
I want to be able to adjust the threshold that the interrupt is triggered.
This project was initially done on picaxe, and will finally end up on a teensy 4.0. However to get a better understanding I ma doing testing and improving my code ability using Arduino.

On the picaxe variant I was able to use an internal voltage ladder to adjust the threshold of the interrupt. However the uno does not appear to have that. This led me to the thinking that routing a PWM to the comparator pin (A0) should do the same thing and also increase the resolution of the threshold.
Is this something that has been done, or have I missed something along the way?

Several ways to do this. The Atmega 328P does have a built in analog comparator. Its use is covered in the data sheet.

Another simple option is find a 10K pot, a 10 turn version would be nice. Connect the ends of the pot between 5 Volts and Ground. Connect the wiper of the pot through about a 250 Ohm resistor to an analog input pin, A0 will do. Now run an analog signal into A1 or any analog in. Write your code so any digital out does whatever you want when A1 is > or < your A0 setpoint. If you want to get cool about it include hysteresis.

I haven't a clue where your reference to PWM figures into this?

Anyway, while overkill there is plenty of ways to use an Arduino as a comparator.

Ron