Electronic – Switching a divided voltage with transistor or MOSFET

microcontrollermosfettransistors

I have a problem that I cannot solve and need help.

I have an analogue input on a microcontroller and I want to have multiple switches which the micro can see and act on depending on which switch was pressed.
I have 5V that the circuit works on. So I am trying to get different voltages from 0-5 into the analog input of the micro.

The catch however is that I want to control it with a p type transistor or MOSFET so that the user can just short something to ground to activate the divided voltage. I've sat here for days trying to figure this out using MOSFETs and transistors but nothing I do works! The divided values are never correct!

I've been playing with BC327's and BS250 MOSFETs to try and make something work, but everything I try fails.

I realize I need help, so I'm throwing this out there on the chance someone can help me!

This is something I tried and failed.

Another failure.

Another failure.

Best Answer

Your circuit won't work when the transistor base is sinking current to ground. Re-position your resistor and try again.

schematic

simulate this circuit – Schematic created using CircuitLab