It's maybe a stupid question, but I have been searching and can't find a good circuit. The thing is, I'm using a comparator which needs a reference signal, the other signal is a amplified pir sensor. But since I want to be capable of adjusting the sensitivity of the sensor I need a variable reference signal without using a whole other power supply. The main supply is 5v. I tried just using a potmeter(variable resistance), but I would need about 20 MOhm , that's kinda rough adjusting, there must be a better and more sensitive solution... I just can't find it Should I use pwm signals or something? I'm using the comparator of a PIC 16f628.