Reading Potentiometers


In this section we now turn our attention to sensors. We'll start off with potentiometers. I suppose it seems funny to consider a pot as a sensor, but it really is. The wiper senses a voltage which will then be passed along to the PIC. Of course, that's analog in nature, but most PICs include analog-to-digital (ADC) circuitry which does a great job of converting the voltage into a binary number.

The PIC Micro Pascal compiler contains a library unit devoted to this function. Despite some of the terminology demanded by the various commands and their parameters, it's very easy to use.

Here's the circuit we'll use for testing:


You'll note that there are two pots in this demo. The commands in the PMP library unit can be used in either 8-bit or 10-bit modes, yielding numbers from 0 to 255 or 1023, respectively. The LCD shows both so you can see what's going on.

Click to get the source code.
Click to get the schematic PDF.

Next Project: Light Sensor

No comments:

Post a Comment