Raspberry Pi lacks ADC functionality that is really necessary when building real world applications. The standard way-out of this situation is to attach external ADC chip that talks to RasPi via SPI or I2C interface. But if you need something that is closer to native peripheral, then take a look at Hussam solution where he builds ADC with comparator circuit.
This solution isn’t something new and was used in recent microcontroller circuits where ADC were needed. Anyway this circuit is useful in many ways – first of all it performs ADC. Second is more educational – it simply reminds (or teaches) how ADC work. Functionality of the circuit is rather simple – it utilized two Raspberry Pi pins where one generates PWM and along with RC filter it gives some voltage level which then is compared to analog voltage source. Code takes care of generating PWM and reading comparator values and this operation is called ‘successive approximation algorithm’. He writhes a thorough explanation on how it works and provides source code to try it out. Currently such ADC was able to generate 750 samples at 8-bit resolution which is not bad for most of analog sensors.