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.
Why do you think you need a 20Meg pot? If your comparator input is high impedance (low current), you can use almost any value pot. Use it in the true potentiometric mode (one end of the pot to +V, one end to -V or gnd, and the wiper to your comparator input), not as a rheostat (variable resistor).