# Reading Analog value from GPIO on STMF103RCT6

I am new to electronics, but have a fair bit of general programming experience, be gentle :)

I have an existing PCB with an STMF103RCT6 where the available pins are GPIO D 0 and GPIO D 1.

I would like to be able to read values of a variable resistor (joystick) - I can see the voltage dropping gradually as I move the joystick forward, but at the moment I am only able to differentiate between full forward (1) and about halfway towards center. I understand that this is where the threshold is crossed, but not sure if there is a way to get at the 'distance' to threshold or the like - I have set the pins to be GPIO_Mode_AIN but not sure if this is a dead end, or if not, where to actually read analog data from.

Do I have options other than involving ADC or adding a capacitor and capturing how long it takes to fill?

Thanks!

• Those pins aren't connected to the internal ADC of that microcontroller, so setting the mode to GPIO_Mode_AIN won't help. Without a respin of your board to free up some pins connected to the ADC, your options really are an external ADC and bit bang an interface on those two GPIOs. – Colin Nov 7 '17 at 12:09
• Agree with Colin__s, or connect an external Joystick to one of already existing ADC modules.There are enough ADC channels on that chip. :) – Abel Tom Mar 13 '18 at 7:09