frasmacon/RPiGPIOTutorials — pull request #1 by jared0x90 (2014-02-06 04:46:53+00:00)
Title: Fixed division problem in MCP3004/MCP3008. 

Hello,

Was watching some of your videos about the MPC3004 on the Raspberry Pi and noticed a slight division error and wanted to send you a fix.

The divisor should be 10.23 as 11 11111111 is 1023 not 1024.
1023 / 10.24 = 99.90234375 instead of 100.

Can create small variance in percentage returned.

For example ADC bits of 10 1110 0110 (742) :

-------------
Python 2.7.5 console:

>>> int(round(742/10.23))
73
>>> int(round(742/10.24))
72
-------------

Thanks for the excellent video!